Skip to main content

nearest

Function nearest 

Source
pub fn nearest<'a, I, S>(input: &str, candidates: I) -> Option<&'a str>
where I: IntoIterator<Item = S>, S: Into<&'a str>,
Expand description

Return the candidate nearest to input within DEFAULT_SUGGESTION_DISTANCE.

Convenience wrapper over nearest_within using the default threshold. See it for the full matching semantics.

ยงExamples

use rskit_util::strings::nearest;
assert_eq!(nearest("fmt", ["format", "test", "lint"]), Some("format"));
assert_eq!(nearest("zzzzz", ["format", "test"]), None);