Skip to main content

closest_match

Function closest_match 

Source
pub fn closest_match<'a>(
    input: &str,
    candidates: &[&'a str],
    max_distance: usize,
) -> Option<&'a str>
Expand description

Returns the closest match to input from candidates, if within max_distance edit distance.

Comparison is case-insensitive. Returns None if no candidate is close enough or if candidates is empty. Exact matches (distance 0) are excluded since they are not typos.