Function rust_fuzzy_search::fuzzy_search_best_n [−][src]
pub fn fuzzy_search_best_n<'a>(
s: &'a str,
list: &'a [&str],
n: usize
) -> Vec<(&'a str, f32)>
This function is similar to fuzzy_search_sorted but keeps only the n
best items, those with a better match.
Arguments :
s
: the string to compare.list
: the list of strings to compare withs
.n
: the number of element to retrieve.
example:
fn test() { use rust_fuzzy_search::fuzzy_search_best_n; let s = "bulko"; let list : Vec<&str> = vec!["kolbasobulko", "sandviĉo"]; let n : usize = 1; let res : Vec<(&str, f32)> = fuzzy_search_best_n(s,&list, n); for (_word, score) in res { println!("{:?}",score) } }Run