fuzzy-search 0.1.0

collections for fuzzy search
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use rayon::prelude::*;

pub fn fuzzy_search<E>(
    query: &str,
    choices: &[String],
    max_edits: usize,
    edit_distance: E,
) -> Vec<String>
where
    E: Fn(&str, &str) -> usize + Sync,
{
    choices
        .par_iter()
        .filter(|choice| (edit_distance)(query, choice) <= max_edits)
        .cloned()
        .collect()
}