Function triple_accel::levenshtein::levenshtein_naive_k[][src]

pub fn levenshtein_naive_k(a: &[u8], b: &[u8], k: u32) -> Option<u32>
Expand description

Returns the Levenshtein distance, bounded by a cost threshold k, between two strings, using the naive scalar algorithm.

This will return None if the Levenshtein distance between a and b is greater than the threshold k. This should be much faster than levenshtein_naive if k is small compared to the lengths of a and b.

Arguments

  • a - first string (slice)
  • b - second string (slice)
  • k - maximum number of edits allowed between a and b

Example

let dist = levenshtein_naive_k(b"abc", b"ab", 1);

assert!(dist.unwrap() == 1);