Skip to main content

Matcher

Trait Matcher 

Source
pub trait Matcher<I: HaystackItem>:
    Debug
    + Default
    + Clone
    + Copy {
    type AllMatches<'a, H: HaystackOf<'a, I>>: Iterator<Item = usize>;
    type AllCaptures<'a, H: HaystackOf<'a, I>>: Iterator<Item = (usize, IndexedCaptures)>;

    // Required methods
    fn matches<'a, H: HaystackOf<'a, I>>(hay: &mut H) -> bool;
    fn all_matches<'a, H: HaystackOf<'a, I>>(
        hay: &mut H,
    ) -> Self::AllMatches<'a, H>;
    fn all_captures<'a, H: HaystackOf<'a, I>>(
        hay: &mut H,
        caps: &mut IndexedCaptures,
    ) -> Self::AllCaptures<'a, H>;

    // Provided method
    fn captures<'a, H: HaystackOf<'a, I>>(
        hay: &mut H,
        caps: &mut IndexedCaptures,
    ) -> bool { ... }
}

Required Associated Types§

Source

type AllMatches<'a, H: HaystackOf<'a, I>>: Iterator<Item = usize>

Source

type AllCaptures<'a, H: HaystackOf<'a, I>>: Iterator<Item = (usize, IndexedCaptures)>

Required Methods§

Source

fn matches<'a, H: HaystackOf<'a, I>>(hay: &mut H) -> bool

Checks if the start of the haystack contains a match for this Matcher. If this method successfully matches the start of the haystack, hay is progressed so that hay.item() hasn’t been matched yet. On a fail, the state of hay is undefined.

Source

fn all_matches<'a, H: HaystackOf<'a, I>>(hay: &mut H) -> Self::AllMatches<'a, H>

Produces a Vec of all valid haystack states produced as the result of a valid match at the start of hay, used to implement backtracking. The Vec is produced in reverse priority order, so the last match has the highest priority. After calling all_matches, the state of hay itself is undefined.

§Required

This method needs to be implemented by all Matchers that can match more than one string of characters from a haystack.

Source

fn all_captures<'a, H: HaystackOf<'a, I>>( hay: &mut H, caps: &mut IndexedCaptures, ) -> Self::AllCaptures<'a, H>

Produces a Vec of all valid captures (and accompanying haystack states) present at the start of hay. Used to implement backtracking for capturing methods. As with all_matches, the resulting Vec is produced in reverse priority order. After calling all_captures, the state of hay and caps are undefined.

§Required

This method needs to be implemented for any type that also implements captures and all_matches.

Provided Methods§

Source

fn captures<'a, H: HaystackOf<'a, I>>( hay: &mut H, caps: &mut IndexedCaptures, ) -> bool

Checks if the start of the haystack contains a match for this Matcher, writing any groups to caps. Similar to matches, this method progresses hay and caps on a success. On a fail, they have undefined states.

§Required

This method needs to be implemented for capturing groups or any type that holds other Matchers, so that it can redirect to the relevant capture methods.

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<I: HaystackItem> Matcher<I> for Always

Source§

impl<I: HaystackItem> Matcher<I> for CRLFEnd

Source§

impl<I: HaystackItem> Matcher<I> for CRLFStart

Source§

impl<I: HaystackItem> Matcher<I> for End

Source§

impl<I: HaystackItem> Matcher<I> for LineEnd

Source§

impl<I: HaystackItem> Matcher<I> for LineStart

Source§

impl<I: HaystackItem> Matcher<I> for Start

Source§

impl<I: HaystackItem, A: Matcher<I>, B: Matcher<I>> Matcher<I> for Or<I, A, B>

Source§

type AllMatches<'a, H: HaystackOf<'a, I>> = Chain<<A as Matcher<I>>::AllMatches<'a, H>, <B as Matcher<I>>::AllMatches<'a, H>>

Source§

type AllCaptures<'a, H: HaystackOf<'a, I>> = Chain<<A as Matcher<I>>::AllCaptures<'a, H>, <B as Matcher<I>>::AllCaptures<'a, H>>

Source§

impl<I: HaystackItem, A: Matcher<I>, B: Matcher<I>> Matcher<I> for Then<I, A, B>

Source§

type AllMatches<'a, H: HaystackOf<'a, I>> = AllMatchesThen<'a, I, H, A, B>

Source§

type AllCaptures<'a, H: HaystackOf<'a, I>> = AllCapturesThen<'a, I, H, A, B>

Source§

impl<I: HaystackItem, A: Matcher<I>, const N: usize> Matcher<I> for CaptureGroup<I, A, N>

Source§

type AllMatches<'a, H: HaystackOf<'a, I>> = <A as Matcher<I>>::AllMatches<'a, H>

Source§

type AllCaptures<'a, H: HaystackOf<'a, I>> = AllCapturesGroup<'a, I, H, A, N>

Source§

impl<I: HaystackItem, A: Matcher<I>, const N: usize> Matcher<I> for QuantifierN<I, A, N>

Source§

impl<I: HaystackItem, A: Matcher<I>, const N: usize> Matcher<I> for QuantifierNOrMore<I, A, N>

Source§

impl<I: HaystackItem, A: Matcher<I>, const N: usize, const M: usize> Matcher<I> for QuantifierNToM<I, A, N, M>

Source§

impl<I: HaystackItem, Q: LazyMatcher<I>> Matcher<I> for Lazy<I, Q>

Source§

type AllMatches<'a, H: HaystackOf<'a, I>> = <Q as LazyMatcher<I>>::LazyAllMatches<'a, H>

Source§

type AllCaptures<'a, H: HaystackOf<'a, I>> = <Q as LazyMatcher<I>>::LazyAllCaptures<'a, H>

Source§

impl<Z: HaystackItem, A: Matcher<Z>, B: Matcher<Z>, C: Matcher<Z>, D: Matcher<Z>> Matcher<Z> for Or4<Z, A, B, C, D>

Source§

type AllMatches<'a, Y: HaystackOf<'a, Z>> = <Or<Z, Or<Z, A, B>, Or<Z, C, D>> as Matcher<Z>>::AllMatches<'a, Y>

Source§

type AllCaptures<'a, Y: HaystackOf<'a, Z>> = <Or<Z, Or<Z, A, B>, Or<Z, C, D>> as Matcher<Z>>::AllCaptures<'a, Y>

Source§

impl<Z: HaystackItem, A: Matcher<Z>, B: Matcher<Z>, C: Matcher<Z>, D: Matcher<Z>> Matcher<Z> for Then4<Z, A, B, C, D>

Source§

type AllMatches<'a, Y: HaystackOf<'a, Z>> = <Then<Z, Then<Z, A, B>, Then<Z, C, D>> as Matcher<Z>>::AllMatches<'a, Y>

Source§

type AllCaptures<'a, Y: HaystackOf<'a, Z>> = <Then<Z, Then<Z, A, B>, Then<Z, C, D>> as Matcher<Z>>::AllCaptures<'a, Y>

Source§

impl<Z: HaystackItem, A: Matcher<Z>, B: Matcher<Z>, C: Matcher<Z>, D: Matcher<Z>, E: Matcher<Z>, F: Matcher<Z>, G: Matcher<Z>, H: Matcher<Z>> Matcher<Z> for Or8<Z, A, B, C, D, E, F, G, H>

Source§

type AllMatches<'a, Y: HaystackOf<'a, Z>> = <Or4<Z, Or<Z, A, B>, Or<Z, C, D>, Or<Z, E, F>, Or<Z, G, H>> as Matcher<Z>>::AllMatches<'a, Y>

Source§

type AllCaptures<'a, Y: HaystackOf<'a, Z>> = <Or4<Z, Or<Z, A, B>, Or<Z, C, D>, Or<Z, E, F>, Or<Z, G, H>> as Matcher<Z>>::AllCaptures<'a, Y>

Source§

impl<Z: HaystackItem, A: Matcher<Z>, B: Matcher<Z>, C: Matcher<Z>, D: Matcher<Z>, E: Matcher<Z>, F: Matcher<Z>, G: Matcher<Z>, H: Matcher<Z>> Matcher<Z> for Then8<Z, A, B, C, D, E, F, G, H>

Source§

type AllMatches<'a, Y: HaystackOf<'a, Z>> = <Then4<Z, Then<Z, A, B>, Then<Z, C, D>, Then<Z, E, F>, Then<Z, G, H>> as Matcher<Z>>::AllMatches<'a, Y>

Source§

type AllCaptures<'a, Y: HaystackOf<'a, Z>> = <Then4<Z, Then<Z, A, B>, Then<Z, C, D>, Then<Z, E, F>, Then<Z, G, H>> as Matcher<Z>>::AllCaptures<'a, Y>

Source§

impl<Z: HaystackItem, A: Matcher<Z>, B: Matcher<Z>, C: Matcher<Z>, D: Matcher<Z>, E: Matcher<Z>, F: Matcher<Z>, G: Matcher<Z>, H: Matcher<Z>, I: Matcher<Z>, J: Matcher<Z>, K: Matcher<Z>, L: Matcher<Z>, M: Matcher<Z>, N: Matcher<Z>, O: Matcher<Z>, P: Matcher<Z>> Matcher<Z> for Or16<Z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>

Source§

type AllMatches<'a, Y: HaystackOf<'a, Z>> = <Or8<Z, Or<Z, A, B>, Or<Z, C, D>, Or<Z, E, F>, Or<Z, G, H>, Or<Z, I, J>, Or<Z, K, L>, Or<Z, M, N>, Or<Z, O, P>> as Matcher<Z>>::AllMatches<'a, Y>

Source§

type AllCaptures<'a, Y: HaystackOf<'a, Z>> = <Or8<Z, Or<Z, A, B>, Or<Z, C, D>, Or<Z, E, F>, Or<Z, G, H>, Or<Z, I, J>, Or<Z, K, L>, Or<Z, M, N>, Or<Z, O, P>> as Matcher<Z>>::AllCaptures<'a, Y>

Source§

impl<Z: HaystackItem, A: Matcher<Z>, B: Matcher<Z>, C: Matcher<Z>, D: Matcher<Z>, E: Matcher<Z>, F: Matcher<Z>, G: Matcher<Z>, H: Matcher<Z>, I: Matcher<Z>, J: Matcher<Z>, K: Matcher<Z>, L: Matcher<Z>, M: Matcher<Z>, N: Matcher<Z>, O: Matcher<Z>, P: Matcher<Z>> Matcher<Z> for Then16<Z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>

Source§

type AllMatches<'a, Y: HaystackOf<'a, Z>> = <Then8<Z, Then<Z, A, B>, Then<Z, C, D>, Then<Z, E, F>, Then<Z, G, H>, Then<Z, I, J>, Then<Z, K, L>, Then<Z, M, N>, Then<Z, O, P>> as Matcher<Z>>::AllMatches<'a, Y>

Source§

type AllCaptures<'a, Y: HaystackOf<'a, Z>> = <Then8<Z, Then<Z, A, B>, Then<Z, C, D>, Then<Z, E, F>, Then<Z, G, H>, Then<Z, I, J>, Then<Z, K, L>, Then<Z, M, N>, Then<Z, O, P>> as Matcher<Z>>::AllCaptures<'a, Y>

Source§

impl<const A: char, const B: char> Matcher<char> for ScalarRange<A, B>

Source§

impl<const A: u8, const B: u8> Matcher<u8> for ByteRange<A, B>

Source§

impl<const N: char> Matcher<char> for Scalar<N>

Source§

impl<const N: u8> Matcher<u8> for Byte<N>