symspell 0.5.2

Spelling correction & Fuzzy search
Documentation
1
2
3
4
5
6
7
8
9
10
11
use strsim::damerau_levenshtein;

pub fn distance(string: &str, other: &str, max_distance: i64) -> i64 {
    let distance = damerau_levenshtein(string, other);

    if distance <= max_distance as usize {
        distance as i64
    } else {
        -1
    }
}