Struct OverlappingState
pub struct OverlappingState { /* private fields */ }
Represents the current state of an overlapping search.
This is used for overlapping searches since they need to know something about the previous search. For example, when multiple patterns match at the same position, this state tracks the last reported pattern so that the next search knows whether to report another matching pattern or continue with the search at the next position. Additionally, it also tracks which state the last search call terminated in and the current offset of the search in the haystack.
This type provides limited introspection capabilities. The only thing a caller can do is construct it and pass it around to permit search routines to use it to track state, and to ask whether a match has been found.
Callers should always provide a fresh state constructed via
OverlappingState::start when starting a new search. That same state
should be reused for subsequent searches on the same Input. The state
given will advance through the haystack itself. Callers can detect the end
of a search when neither an error nor a match is returned.
Example
This example shows how to manually iterate over all overlapping matches. If
you need this, you might consider using
AhoCorasick::find_overlapping_iter
instead, but this shows how to correctly use an OverlappingState.
use ;
let patterns = &;
let haystack = "append the app to the appendage";
let ac = new.unwrap;
let mut state = start;
let mut matches = vec!;
loop
let expected = vec!;
assert_eq!;
Implementations
impl OverlappingState
fn start() -> OverlappingStateCreate a new overlapping state that begins at the start state.
fn get_match(&self) -> Option<Match>Return the match result of the most recent search to execute with this state.
Every search will clear this result automatically, such that if no match is found, this will always correctly report
None.
Trait Implementations
impl Clone for OverlappingState
fn clone(&self) -> Self
impl Debug for OverlappingState
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl Freeze for OverlappingState
impl RefUnwindSafe for OverlappingState
impl Send for OverlappingState
impl Sync for OverlappingState
impl Unpin for OverlappingState
impl UnsafeUnpin for OverlappingState
impl UnwindSafe for OverlappingState
Blanket Implementations
impl<T> Any for OverlappingState
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for OverlappingState
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for OverlappingState
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for OverlappingState
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for OverlappingState
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for OverlappingState
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for OverlappingState
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for OverlappingState
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for OverlappingState
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>