pub fn distance<T: PartialEq, U: AsRef<[T]>>(a: U, b: U) -> usizeExpand description
Compute the Levenshtein distance between two sequences using identical weights for insertions/deletions and for substitutions.
ยงExamples:
- Compute a distance in characters between two strings:
assert_eq!(distance ("abc", "aaxcc"), 3);- Compute a distance in words between two strings:
assert_eq!(
distance (
"The quick brown fox".split (' ').collect::<Vec<_>>(),
"The very quick brown cat".split (' ').collect()),
2);- Compute a distance between two sequences of anything:
assert_eq!(distance (vec![1, 2, 3], vec![0, 1, 3, 3, 4]), 3);