Function fuzzy_match::fuzzy_match_with_algorithms[][src]

pub fn fuzzy_match_with_algorithms<'a, T, FST, SND, It>(
    needle: &str,
    haystack: It
) -> Option<T> where
    FST: SimilarityAlgorithm,
    SND: SimilarityAlgorithm,
    It: IntoIterator<Item = (&'a str, T)>, 

Version of fuzzy_match which allows overriding the first and second choice algorithms, instead of using Sorensen-Dice and Levenshtein respectively. This consumes the input vector.

Examples

use fuzzy_match::fuzzy_match_with_algorithms;
use fuzzy_match::algorithms::{SorensenDice, Levenshtein};

let haystack = vec![("rust", 0), ("java", 1), ("lisp", 2)];
// Search with Levenshtein first, then Sorensen-Dice.
assert_eq!(Some(0), fuzzy_match_with_algorithms::<_, Levenshtein, SorensenDice, _>("bust", haystack));

Panics

This function will panic if the haystack is empty (length 0).