find
fn find(Vec<byte> hay, Vec<byte> needle) -> int Import
Source: use bytes::{find}; src/bytes.hy Returns the offset of the first needle in hay, or -1. An empty needle matches at 0.
Parameters#
| Name | Type |
|---|---|
hay | Vec<byte> |
needle | Vec<byte> |
Returns#
int
Examples#
use bytes::{find};
use tests::assert;
assert!(find("a,b,c", ",") == 1);
assert!(find("abc", "x") == -1);
See also#
region_eq: True whena[ao..ao+n)equalsb[bo..bo+n)(caller guarantees bounds).to_hex: Encodesbufas lowercase hexadecimal, two digits per byte.from_hex: Decodes hexadecimal text (either case) into bytes.slice: Returns a copy ofsrc[start..end](end exclusive), with both offsets clamped to the buffer.concat: Returns a new buffer holdingafollowed byb.eq: Returnstruewhenaandbhave the same length and the same bytes.find_from: Returns the offset of the firstneedleinhayat or afterstart, or-1.rfind: Returns the offset of the lastneedleinhay, or-1.