Calculating the distance between two collections, where one collection is an exact copy of the other except for the presence of the first item, appears to result in an invalid distance matrix:
fn main() {
let collection_1: Vec<String> = vec!["Hello".into(), "World".into()];
let collection_2: Vec<String> = vec!["World".into()];
let (distance, matrix) = levenshtein_diff::distance(&collection_1, &collection_2);
let _edits = levenshtein_diff::generate_edits(&collection_1, &collection_2, &matrix);
println!("levenshtein distance of {distance}");
}
Error log:
Compiling test-crate v0.1.0 (C:\Users\<private>\test)
Finished dev [unoptimized + debuginfo] target(s) in 0.50s
Running `target\debug\test-crate.exe`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidDistanceMatrixError', src\main.rs:6:90
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\test-crate.exe` (exit code: 101)
This also appears to occur when the first and second items are swapped:
fn main() {
let collection_1: Vec<String> = vec!["Hello".into(), "World".into()];
let collection_2: Vec<String> = vec!["World".into(), "Hello".into()];
let (distance, matrix) = levenshtein_diff::distance(&collection_1, &collection_2);
let _edits = levenshtein_diff::generate_edits(&collection_1, &collection_2, &matrix); // thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidDistanceMatrixError', src\main.rs:6:90
println!("levenshtein distance of {distance}");
}