Struct fuzzy_trie::FuzzyTrie
source · [−]pub struct FuzzyTrie<T> { /* private fields */ }
Expand description
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
sourceimpl<T> FuzzyTrie<T>
impl<T> FuzzyTrie<T>
sourcepub fn new(distance: u8, damerau: bool) -> Self
pub fn new(distance: u8, damerau: bool) -> Self
Creates new fuzzy trie with given distance and dameru params
sourcepub fn new_with_config(config: &Config) -> Self
pub fn new_with_config(config: &Config) -> Self
Creates new fuzzy trie from given config
sourcepub fn insert<'a>(&'a mut self, key: &str) -> Inserter<'a, T>
pub fn insert<'a>(&'a mut self, key: &str) -> Inserter<'a, T>
Inserts value to trie
Returns inserter, to make possible using the value field as a key
See Inserter
for additional information
sourcepub fn fuzzy_search<'a, C: Collector<'a, T>>(&'a self, key: &str, out: &mut C)
pub fn fuzzy_search<'a, C: Collector<'a, T>>(&'a self, key: &str, out: &mut C)
Makes fuzzy search with given key and puts result to out collector
See Collector
for additional information
sourcepub fn prefix_fuzzy_search<'a, C: Collector<'a, T>>(
&'a self,
key: &str,
out: &mut C
)
pub fn prefix_fuzzy_search<'a, C: Collector<'a, T>>(
&'a self,
key: &str,
out: &mut C
)
Makes fuzzy search on prefix with given key and puts result to out collector
See Collector
for additional information
sourcepub fn into_values(self) -> Vec<T>
pub fn into_values(self) -> Vec<T>
Destructs self into inner vec of values
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more