pub fn close_enough<I, O, Q>(options: I, query: Q) -> Option<O>where
    I: IntoIterator<Item = O>,
    O: AsRef<str>,
    Q: AsRef<str>,
Expand description

Returns the closest match from the given options to the given query.

This algorithm works by scanning through each option trying to match the beginning of the query. Once a match has begun, any non-matching characters will cause the scan to skip to the next word of the option. If the end of the option is reached before the entire query has been matched somewhere, the option is considered not to match.

If multiple options match, it returns the shortest.

Examples

let options = &["one two", "three four", "five six"];
let query = "owo";
let result = close_enough::close_enough(options, query);
assert_eq!(result, Some(&"one two"));