pub trait RegexMatcher<A>: Clone {
    // Required methods
    fn step(&mut self, inp: A);
    fn is_final(&self) -> bool;
    fn is_accepting(&self) -> bool;

    // Provided methods
    fn step_many(&mut self, inp: impl IntoIterator<Item = A>) { ... }
    fn step_unless_empty(&mut self, inp: impl IntoIterator<Item = A>) { ... }
    fn accepts(&self, iter: impl IntoIterator<Item = A>) -> bool { ... }
    fn accepts_prefix(&self, iter: impl IntoIterator<Item = A>) -> bool { ... }
    fn is_empty(&self) -> bool { ... }
}
Expand description

A type that can match a regex. Can be created at compile time through the compile_regex macro, or at runtime with the dynamic feature through [Automaton::matcher].

Required Methods§

source

fn step(&mut self, inp: A)

Takes a transition in the state machine, accepting a single symbol.

If the symbol was not accepted, because the regex doesn’t allow it, the new state is empty, which can be checked using RegexMatcher::is_empty.

source

fn is_final(&self) -> bool

Returns whether this state is a final state.

A Final state is a state without outgoing edges

source

fn is_accepting(&self) -> bool

Returns whether the current state would accept the regular expression.

Provided Methods§

source

fn step_many(&mut self, inp: impl IntoIterator<Item = A>)

Steps once for each element in the iterator

source

fn step_unless_empty(&mut self, inp: impl IntoIterator<Item = A>)

Steps once for each element in the iterator

source

fn accepts(&self, iter: impl IntoIterator<Item = A>) -> bool

Returns true if the regular expression accepts the input iterator

source

fn accepts_prefix(&self, iter: impl IntoIterator<Item = A>) -> bool

Returns true if the regular expression accepts a word of which the input iterator is a prefix

source

fn is_empty(&self) -> bool

Returns whether the regular expression is stuck: there are no more outgoing edges and it’s not currently accepting.

Object Safety§

This trait is not object safe.

Implementors§