pub struct DFA { /* private fields */ }
Expand description

Implementation of a Deterministic Finite Automaton for a Levenshtein Automaton targeting UTF-8 encoded strings.

The automaton does not validate utf-8. It will not return errors when fed with invalid utf-8

The only sink state is guaranteed to be SINK.

This means that if you reach the sink state you are guaranteed that regardless of the sequence of bytes you might consume in the future, you will always remain in the same state.

This property can be exploited to abort further evaluation.

Usage

let mut state = dfa.initial_state();
for &byte in str.as_bytes() {
    state = dfa.transition(state, byte);
    if state == SINK_STATE {
        break;
    }
}
let distance = dfa.distance(state);

Implementations

Returns the initial state

Helper function that consumes all of the bytes a sequence of bytes and returns the resulting distance.

Returns the Levenshtein distance associated to the current state.

Returns the number of states in the DFA.

Returns the destination state reached after consuming a given byte.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.