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§
sourcefn step(&mut self, inp: A)
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.
sourcefn is_final(&self) -> bool
fn is_final(&self) -> bool
Returns whether this state is a final state.
A Final state is a state without outgoing edges
sourcefn is_accepting(&self) -> bool
fn is_accepting(&self) -> bool
Returns whether the current state would accept the regular expression.
Provided Methods§
sourcefn step_many(&mut self, inp: impl IntoIterator<Item = A>)
fn step_many(&mut self, inp: impl IntoIterator<Item = A>)
Steps once for each element in the iterator
sourcefn step_unless_empty(&mut self, inp: impl IntoIterator<Item = A>)
fn step_unless_empty(&mut self, inp: impl IntoIterator<Item = A>)
Steps once for each element in the iterator
sourcefn accepts(&self, iter: impl IntoIterator<Item = A>) -> bool
fn accepts(&self, iter: impl IntoIterator<Item = A>) -> bool
Returns true if the regular expression accepts the input iterator
sourcefn accepts_prefix(&self, iter: impl IntoIterator<Item = A>) -> bool
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