weighted_levenshtein

Trait EditWeight

Source
pub trait EditWeight {
    // Required methods
    fn add_cost(&self) -> usize;
    fn rm_cost(&self) -> usize;
    fn sub_cost(&self, other: &Self) -> usize;
}
Expand description

Trait for types that have custom costs for addition/removal and substitution.

Required Methods§

Source

fn add_cost(&self) -> usize

Cost of adding this item to a sequence

Source

fn rm_cost(&self) -> usize

Cost of removing this item from a sequence

Source

fn sub_cost(&self, other: &Self) -> usize

Cost of substituting other for this item. Note: edit distance is only well-defined when self.sub_cost(&self) == 0

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl EditWeight for &str

Source§

fn add_cost(&self) -> usize

Source§

fn rm_cost(&self) -> usize

Source§

fn sub_cost(&self, other: &Self) -> usize

Source§

impl EditWeight for u8

Source§

fn add_cost(&self) -> usize

Source§

fn rm_cost(&self) -> usize

Source§

fn sub_cost(&self, other: &Self) -> usize

Implementors§