pub struct IdentifyDistinct<Int> { /* private fields */ }
Expand description

A utility struct to convert distinct items to unique integers.

This can be helpful on larger inputs to speed up the comparisons performed by doing a first pass where the data set gets reduced to (small) integers.

The idea is that instead of passing two sequences to a diffling algorithm you first pass it via IdentifyDistinct:

use similar::capture_diff;
use similar::algorithms::{Algorithm, IdentifyDistinct};

let old = &["foo", "bar", "baz"][..];
let new = &["foo", "blah", "baz"][..];
let h = IdentifyDistinct::<u32>::new(old, 0..old.len(), new, 0..new.len());
let ops = capture_diff(
    Algorithm::Myers,
    h.old_lookup(),
    h.old_range(),
    h.new_lookup(),
    h.new_range(),
);

The indexes are the same as with the passed source ranges.

Implementations§

Creates an int hasher for two sequences.

Returns a lookup for the old side.

Returns a lookup for the new side.

Convenience method to get back the old range.

Convenience method to get back the new range.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.