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
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.