Function similar::get_close_matches

source ยท
pub fn get_close_matches<'a, T: DiffableStr + ?Sized>(
    word: &T,
    possibilities: &[&'a T],
    n: usize,
    cutoff: f32,
) -> Vec<&'a T>
Expand description

Use the text differ to find n close matches.

cutoff defines the threshold which needs to be reached for a word to be considered similar. See TextDiff::ratio for more information.

let matches = get_close_matches(
    "appel",
    &["ape", "apple", "peach", "puppy"][..],
    3,
    0.6
);
assert_eq!(matches, vec!["apple", "ape"]);

Requires the text feature.