[][src]Struct fst::automaton::Subsequence

pub struct Subsequence<'a> { /* fields omitted */ }

An automaton that matches if the input contains a specific subsequence.

It can be used to build a simple fuzzy-finder.

extern crate fst;

use fst::{IntoStreamer, Streamer, Set};
use fst::automaton::Subsequence;

fn example() -> Result<(), Box<dyn std::error::Error>> {
    let paths = vec!["/home/projects/bar", "/home/projects/foo", "/tmp/foo"];
    let set = Set::from_iter(paths)?;

    // Build our fuzzy query.
    let subseq = Subsequence::new("hpf");

    // Apply our fuzzy query to the set we built.
    let mut stream = set.search(subseq).into_stream();

    let matches = stream.into_strs()?;
    assert_eq!(matches, vec!["/home/projects/foo"]);
    Ok(())
}

Methods

impl<'a> Subsequence<'a>[src]

pub fn new(subsequence: &'a str) -> Subsequence<'a>[src]

Constructs automaton that matches input containing the specified subsequence.

Trait Implementations

impl<'a> Automaton for Subsequence<'a>[src]

type State = usize

The type of the state used in the automaton.

impl<'a> Clone for Subsequence<'a>[src]

impl<'a> Debug for Subsequence<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Subsequence<'a>

impl<'a> Send for Subsequence<'a>

impl<'a> Sync for Subsequence<'a>

impl<'a> Unpin for Subsequence<'a>

impl<'a> UnwindSafe for Subsequence<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.