Function find
pub fn find<H, N>(haystack: H, needle: N) -> Option<usize> ⓘ
Available on crate feature
dep_stringzilla
only.Expand description
Locates the first matching substring within haystack
that equals needle
.
This function is similar to the memmem()
function in LibC, but, unlike strstr()
,
it requires the length of both haystack and needle to be known beforehand.
§Arguments
haystack
: The byte slice to search.needle
: The byte slice to find within the haystack.
§Returns
An Option<usize>
representing the starting index of the first occurrence of needle
within haystack
if found, otherwise None
.