[][src]Struct fst::automaton::Str

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

An automaton that matches if the input equals to a specific string.

It can be used in combination with StartsWith to search strings starting with a given prefix.

extern crate fst;

use fst::{Automaton, IntoStreamer, Streamer, Set};
use fst::automaton::Str;

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 prefix query.
    let prefix = Str::new("/home").starts_with();

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

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

Implementations

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

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

Constructs automaton that matches an exact string.

Trait Implementations

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

type State = Option<usize>

The type of the state used in the automaton.

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

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

Auto Trait Implementations

impl<'a> RefUnwindSafe for Str<'a>

impl<'a> Send for Str<'a>

impl<'a> Sync for Str<'a>

impl<'a> Unpin for Str<'a>

impl<'a> UnwindSafe for Str<'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.