Struct Levenshtein

Source
pub struct Levenshtein<T = Symbols> { /* private fields */ }
Expand description

levenshtein distance metric for strings

Implementations§

Source§

impl Levenshtein<Symbols>

Source

pub fn new() -> Self

creates a new levenshtein distance metric

Examples found in repository?
examples/string_matching.rs (line 2)
1pub fn main(){
2	let mut tree=BKTreeMap::new(Levenshtein::new());
3	tree.insert("calculate","mathematics");
4	tree.insert("cat","pet");
5	tree.insert("kat","name");
6	tree.insert("hello","greeting");
7	tree.insert("hi","greeting");
8	tree.insert("linear","mathematics");
9
10	println!("{}",tree.get("calculator",2).map(|(s,_d)|*s).unwrap_or("not found"));
11	println!("{}",tree.get("hey",2).map(|(s,_d)|*s).unwrap_or("not found"));
12	println!("{}",tree.get("kate",2).map(|(s,_d)|*s).unwrap_or("not found"));
13	println!("{}",tree.get("line",2).map(|(s,_d)|*s).unwrap_or("not found"));
14	println!("{}",tree.get("serotonin",2).map(|(s,_d)|*s).unwrap_or("not found"));
15}
Source§

impl<T> Levenshtein<T>

Source

pub fn new_for(t: T) -> Self

creates a new levenshtein distance metric

Trait Implementations§

Source§

impl<T> AsMut<Levenshtein<T>> for Levenshtein<T>

Source§

fn as_mut(&mut self) -> &mut Self

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T> AsRef<Levenshtein<T>> for Levenshtein<T>

Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone> Clone for Levenshtein<T>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Levenshtein<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for Levenshtein<T>

Source§

fn default() -> Levenshtein<T>

Returns the “default value” for a type. Read more
Source§

impl<U: ?Sized + SymbolIter, V: ?Sized + SymbolIter<Item = U::Item>> DiscreteMetric<U, V> for Levenshtein<Symbols>

Source§

fn distance(&self, u: &U, v: &V) -> usize

computes the distance between two elements of the metric space
Source§

impl<U: ?Sized + AsRef<str>, V: ?Sized + AsRef<str>> DiscreteMetric<U, V> for Levenshtein<StrRef>

Source§

fn distance(&self, u: &U, v: &V) -> usize

computes the distance between two elements of the metric space

Auto Trait Implementations§

§

impl<T = Symbols> !Freeze for Levenshtein<T>

§

impl<T> RefUnwindSafe for Levenshtein<T>
where T: RefUnwindSafe,

§

impl<T> Send for Levenshtein<T>
where T: Send,

§

impl<T> Sync for Levenshtein<T>
where T: Sync,

§

impl<T> Unpin for Levenshtein<T>
where T: Unpin,

§

impl<T> UnwindSafe for Levenshtein<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.