pub fn find_iter<'h, 'n, N: 'n + ?Sized + AsRef<[u8]>>(
haystack: &'h [u8],
needle: &'n N
) -> FindIter<'h, 'n>ⓘNotable traits for FindIter<'h, 'n>impl<'h, 'n> Iterator for FindIter<'h, 'n> type Item = usize;
Expand description
Returns an iterator over all occurrences of a substring in a haystack.
Complexity
This routine is guaranteed to have worst case linear time complexity
with respect to both the needle and the haystack. That is, this runs
in O(needle.len() + haystack.len())
time.
This routine is also guaranteed to have worst case constant space complexity.
Examples
Basic usage:
use memchr::memmem;
let haystack = b"foo bar foo baz foo";
let mut it = memmem::find_iter(haystack, b"foo");
assert_eq!(Some(0), it.next());
assert_eq!(Some(8), it.next());
assert_eq!(Some(16), it.next());
assert_eq!(None, it.next());