Function code_fuzzy_match::fuzzy_match
source · pub fn fuzzy_match(target: &str, query: &str) -> Option<usize>Expand description
Fuzzy match a string against a query string. Returns a score that is higher for
a more confident match, or None if the query does not match the target string.
When performing a large batch of fuzzy matches, use FuzzyMatcher instead.
§Examples
let matches = code_fuzzy_match::fuzzy_match("the quick brown fox", "bro fox");
assert!(matches.is_some());
let no_match = code_fuzzy_match::fuzzy_match("the quick brown fox", "cat");
assert!(no_match.is_none());
let high_score = code_fuzzy_match::fuzzy_match("Example string", "example");
let lower_score = code_fuzzy_match::fuzzy_match("Example string", "str");
assert!(high_score.unwrap() > lower_score.unwrap());