RegexMatcher

Trait RegexMatcher 

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

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§