Skip to content

Commit 4532d20

Browse files
committed
A little more correct.
1 parent caf7248 commit 4532d20

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/cargo/util/lev_distance.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
use std::cmp;
22

33
pub fn lev_distance(me: &str, t: &str) -> usize {
4+
let t_len = t.chars().count();
45
if me.is_empty() {
5-
return t.chars().count();
6+
return t_len;
67
}
78
if t.is_empty() {
89
return me.chars().count();
910
}
1011

11-
let mut dcol = (0..=t.len()).collect::<Vec<_>>();
12+
let mut dcol = (0..=t_len).collect::<Vec<_>>();
1213
let mut t_last = 0;
1314

1415
for (i, sc) in me.chars().enumerate() {

0 commit comments

Comments
 (0)