Use unwrap_or (#56)

This commit is contained in:
Mads Marquart 2023-12-29 20:56:48 +01:00 committed by GitHub
parent 2b31f65445
commit f5c1afa8f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -95,8 +95,8 @@ where
d.equal(old_orig_idx, new_orig_idx, 1)?;
old_idx += 1;
new_idx += 1;
} else if table.get(&(new_idx, old_idx + 1)).map_or(0, |&x| x)
>= table.get(&(new_idx + 1, old_idx)).map_or(0, |&x| x)
} else if table.get(&(new_idx, old_idx + 1)).unwrap_or(&0)
>= table.get(&(new_idx + 1, old_idx)).unwrap_or(&0)
{
d.delete(old_orig_idx, 1, new_orig_idx)?;
old_idx += 1;
@ -166,12 +166,12 @@ where
for j in (0..old_len).rev() {
let val = if new[i] == old[j] {
table.get(&(i + 1, j + 1)).map_or(0, |&x| x) + 1
table.get(&(i + 1, j + 1)).unwrap_or(&0) + 1
} else {
table
*table
.get(&(i + 1, j))
.map_or(0, |&x| x)
.max(table.get(&(i, j + 1)).map_or(0, |&x| x))
.unwrap_or(&0)
.max(table.get(&(i, j + 1)).unwrap_or(&0))
};
if val > 0 {
table.insert((i, j), val);