pub struct Finder(_);
Expand description
A forward substring searcher that uses the Two-Way algorithm.
Implementations§
source§impl Finder
impl Finder
sourcepub fn new(needle: &[u8]) -> Finder
pub fn new(needle: &[u8]) -> Finder
Create a searcher that finds occurrences of the given needle
.
An empty needle
results in a match at every position in a haystack,
including at haystack.len()
.
sourcepub fn find(&self, haystack: &[u8], needle: &[u8]) -> Option<usize>
pub fn find(&self, haystack: &[u8], needle: &[u8]) -> Option<usize>
Returns the first occurrence of needle
in the given haystack
, or
None
if no such occurrence could be found.
The needle
given must be the same as the needle
provided to
Finder::new
.
An empty needle
results in a match at every position in a haystack,
including at haystack.len()
.