pub struct Finder(TwoWay);
Expand description
A forward substring searcher that uses the Two-Way algorithm.
Tuple Fields§
§0: TwoWay
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()
.
sourcepub(crate) fn find_with_prefilter(
&self,
pre: Option<Pre<'_>>,
haystack: &[u8],
needle: &[u8],
) -> Option<usize>
pub(crate) fn find_with_prefilter( &self, pre: Option<Pre<'_>>, haystack: &[u8], needle: &[u8], ) -> Option<usize>
This is like Finder::find
, but it accepts a prefilter for
accelerating searches.
Currently this is not exposed in the public API because, at the time
of writing, I didn’t want to spend time thinking about how to expose
the prefilter infrastructure (if at all). If you have a compelling use
case for exposing this routine, please create an issue. Do not open
a PR that just exposes Pre
and friends. Exporting this routine will
require API design.
fn find_small_imp( &self, pre: Option<Pre<'_>>, haystack: &[u8], needle: &[u8], period: usize, ) -> Option<usize>
fn find_large_imp( &self, pre: Option<Pre<'_>>, haystack: &[u8], needle: &[u8], shift: usize, ) -> Option<usize>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Finder
impl RefUnwindSafe for Finder
impl Send for Finder
impl Sync for Finder
impl Unpin for Finder
impl UnwindSafe for Finder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)