Skip to main content

Anchor

Trait Anchor 

Source
pub trait Anchor:
    Sealed
    + Debug
    + Default
    + Clone
    + Copy {
    // Required methods
    fn assert<'a, H: Haystack<'a>>(hay: &H) -> ControlFlow<(), bool>;
    fn assert_fixed<'a, H: Haystack<'a>>(hay: &H) -> bool;
}

Required Methods§

Source

fn assert<'a, H: Haystack<'a>>(hay: &H) -> ControlFlow<(), bool>

Asserts that each anchor in this set could possibly succeed with the given haystack state. In the presence of a start anchor, the haystack’s position at the start doesn’t need to be checked again.

The return value represents two things:

  • The outer ControlFlow represents whether the haystack has reached a point of no-return. If the value is ControlFlow::Break, no more matches will succeed; no further attempts should be made to match against the haystack. For functions that return an option, it should be possible to try the return value with .continue_value()?.

  • If the value of the outer type is ControlFlow::Continue, the inner bool represents whether the current position should be checked for a match. A value of false indicates that the haystack should be progressed before checking again.

Source

fn assert_fixed<'a, H: Haystack<'a>>(hay: &H) -> bool

Asserts that each anchor in this set could possibly succeed with the given haystack state. In the presence of a start anchor, the haystack’s position at the start doesn’t need to be checked again. This variant provide no information about whether the search should continue and should be called by searches that intend to match the entirety of the provided haystack.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Anchor for AnchorNone

Source§

impl Anchor for Start

Source§

impl<A: Anchor, B: Anchor> Anchor for AnchorPair<A, B>

Source§

impl<A: Anchor, B: Anchor, C: Anchor> Anchor for AnchorSet<A, B, C>

Source§

impl<const N: usize> Anchor for EndAndMaxLen<N>

Source§

impl<const N: usize> Anchor for MaxLen<N>

Source§

impl<const N: usize> Anchor for MinLen<N>