Skip to main content

Dfa

Struct Dfa 

Source
pub struct Dfa { /* private fields */ }
Expand description

Lazy DFA for fast exact matching.

Implementations§

Source§

impl Dfa

Source

pub fn from_nfa( nfa: &Nfa, bridge: Option<&FuzzyBridge>, case_insensitive: bool, multi_line: bool, ) -> Option<Self>

Create a new DFA from an NFA. Returns None if the NFA contains states that can’t be converted to DFA (fuzzy matching with edits, lookahead/lookbehind, backreferences).

If bridge is provided, exact FuzzyLiteral states will be expanded. If case_insensitive is true, matching will be case-insensitive. If multi_line is true, ^ and $ will match at line boundaries.

Source

pub fn find(&mut self, text: &str) -> Option<DfaMatch>

Find the first match in the text.

Source

pub fn find_all(&mut self, text: &str) -> Vec<DfaMatch>

Find all non-overlapping matches.

Source

pub fn find_n(&mut self, text: &str, n: usize) -> Vec<DfaMatch>

Find the first n non-overlapping matches.

Source

pub fn is_anchored_start(&self) -> bool

Check if the DFA is anchored at start.

Source

pub fn is_anchored_end(&self) -> bool

Check if the DFA is anchored at end.

Source

pub fn state_count(&self) -> usize

Get the number of states in the DFA.

Source

pub fn minimize(&mut self) -> usize

Minimize the DFA using Hopcroft’s algorithm. Returns the number of states removed.

Trait Implementations§

Source§

impl Debug for Dfa

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Dfa

§

impl !RefUnwindSafe for Dfa

§

impl !Send for Dfa

§

impl !Sync for Dfa

§

impl Unpin for Dfa

§

impl UnsafeUnpin for Dfa

§

impl !UnwindSafe for Dfa

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.