pub struct Levenshtein { /* private fields */ }Expand description
Holds custom weights for substitutions and insertion/deletion
§Examples
- One substitution is equivalent to an insertion and a deletion:
let lev = Levenshtein::new (1, 2);
// Substitute 'x' for 'b' -> cost = 2
assert_eq!(lev.distance ("abc", "axc"), 2);
// Insert 'x' and delete 'c' -> cost = 1+1 = 2
assert_eq!(lev.distance ("abc", "xab"), 2);- Have substitutions cost slightly more than insertions and deletions (but still less than a deletion followed by an insertion):
let lev = Levenshtein::new (2, 3);
// Substitute 'x' for 'b' -> cost = 3
assert_eq!(lev.distance ("abc", "axc"), 3);
// Insert 'x' and delete 'c' -> cost = 2+2 = 4
assert_eq!(lev.distance ("abc", "xab"), 4);Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Levenshtein
impl RefUnwindSafe for Levenshtein
impl Send for Levenshtein
impl Sync for Levenshtein
impl Unpin for Levenshtein
impl UnwindSafe for Levenshtein
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more