agnostic-levenshtein 0.1.2

Levenshtein distance for ASCII or Unicode strings
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 6.29 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 162.23 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • theodore-s-beers/agnostic-levenshtein
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • theodore-s-beers

agnostic-levenshtein

After doing the LeetCode problem on the edit distance between two strings—which in this case refers to the Levenshtein distance—I became quite enamored of the algorithm and wanted to write my own implementation in Rust. That's all this is.

I wrote my version such that the function edit_distance takes three arguments: two &str and a bool flag for "ASCII mode." When this flag is set, the algorithm will work directly with the bytes of the strings, rather than building Vecs of their 32-bit (i.e., UTF-32) char values. This should be faster and avoid some allocation, as far as I understand. I wonder if there might be a more efficient approach for the Unicode case.

Either way, the return value is the Levenshtein distance as u32. It may be worth noting that input strings of length greater than u32::MAX will not yield correct results—though I can hardly imagine that problem arising in practice.