[][src]Struct fuzzy_trie::FuzzyTrie

pub struct FuzzyTrie<T> { /* fields omitted */ }

FuzzyTrie is a trie with a LevensteinAutomata to make fuzzy searches

Example

use fuzzy_trie::FuzzyTrie;
 
let mut trie = FuzzyTrie::new(2, false);
trie.insert("vanilla").insert("vanilla item");
trie.insert("hello").insert("hello item");
trie.insert("helo").insert("helo item");
trie.insert("vanllo").insert("vanllo item");


let mut hello = Vec::new();
trie.fuzzy_search("hello", &mut hello);
let mut hello_iter = hello.into_iter();

assert_eq!(hello_iter.next(), Some((0, &"hello item")));
assert_eq!(hello_iter.next(), Some((1, &"helo item")));
assert_eq!(hello_iter.next(), None);


let mut vanila = Vec::new();
trie.fuzzy_search("vanilla", &mut vanila);
let mut vanila_iter = vanila.into_iter();

assert_eq!(vanila_iter.next(), Some((0, &"vanilla item")));
assert_eq!(vanila_iter.next(), Some((2, &"vanllo item")));
assert_eq!(vanila_iter.next(), None);

Implementations

impl<T> FuzzyTrie<T>[src]

pub fn new(distance: u8, damerau: bool) -> Self[src]

Creates new fuzzy trie with given distance and dameru params

pub fn new_with_config(config: &Config) -> Self[src]

Creates new fuzzy trie from given config

pub fn insert<'a>(&'a mut self, key: &str) -> Inserter<'a, T>[src]

Inserts value to trie Returns inserter, to make possible using the value field as a key See Inserter for additional information

Makes fuzzy search with given key and puts result to out collector See Collector for additional information

pub fn iter(&self) -> Iter<T>[src]

Iterator over values

pub fn into_value(self) -> Vec<T>[src]

Destructs self into inner vec of values

pub fn len(&self) -> usize[src]

Len of inner values vector

Auto Trait Implementations

impl<T> RefUnwindSafe for FuzzyTrie<T> where
    T: RefUnwindSafe

impl<T> Send for FuzzyTrie<T> where
    T: Send

impl<T> Sync for FuzzyTrie<T> where
    T: Sync

impl<T> Unpin for FuzzyTrie<T> where
    T: Unpin

impl<T> UnwindSafe for FuzzyTrie<T> where
    T: UnwindSafe

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