Rust Levenshtein CLI
Rust Levenshtein — a runnable rust project with source, install and run commands, and expected output.
Project
rust-levenshtein-cli
Entry point: main.rs
Install
cargo run -- kitten sittingRun
cargo run -- kitten sittingTest
cargo testExpected output
Computes Levenshtein edit distance between two strings.Dependencies
- rust >=1.75
Verification evidence
Source reviewed against rust standard library APIs. Commands verified for syntax; execution not yet exercised in CI.
Security note
Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.
What it does
Rust Levenshtein CLI is a self-contained rust command-line program. Computes Levenshtein edit distance between two strings.
Install and run
cargo run -- kitten sitting
cargo run -- kitten sitting
Project structure
rust-levenshtein-cli/
├── main.rs
└── README snippet above
Key source
// main.rs
use std::env; fn lev(a: &str, b: &str) -> usize {
let a: Vec<char> = a.chars().collect(); let b: Vec<char> = b.chars().collect();
let mut d = vec![vec![0; b.len()+1]; a.len()+1];
for i in 0..=a.len() { d[i][0] = i; } for j in 0..=b.len() { d[0][j] = j; }
for i in 1..=a.len() { for j in 1..=b.len() { let c = if a[i-1]==b[j-1] {0} else {1}; d[i][j] = (d[i-1][j]+1).min(d[i][j-1]+1).min(d[i-1][j-1]+c); } }
d[a.len()][b.len()]
} fn main() { let a: Vec<String> = env::args().collect(); println!("{}", lev(&a[1], &a[2])); }
Testing
cargo test
Expected output
When run with the documented command, the program prints:
3
This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.
Limitations
- The program is a single-file CLI with no external service dependencies.
- Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
- Execution has been reviewed for correctness but not yet exercised in an automated CI run.