pub struct Changeset {
    pub diffs: Vec<Difference>,
    pub split: String,
    pub distance: i32,
}
Expand description

The information about a full changeset

Fields

diffs: Vec<Difference>

An ordered vector of Difference objects, coresponding to the differences within the text

split: String

The split used when creating the Changeset Common splits are "" for char-level, " " for word-level and "\n" for line-level.

distance: i32

The edit distance of the Changeset

Implementations

Calculates the edit distance and the changeset for two given strings. The first string is assumed to be the “original”, the second to be an edited version of the first. The third parameter specifies how to split the input strings, leading to a more or less exact comparison.

Common splits are "" for char-level, " " for word-level and "\n" for line-level.

Outputs the edit distance (how much the two strings differ) and a “changeset”, that is a Vec containing Differences.

Examples
use difference::{Changeset, Difference};

let changeset = Changeset::new("test", "tent", "");

assert_eq!(changeset.diffs, vec![
    Difference::Same("te".to_string()),
    Difference::Rem("s".to_string()),
    Difference::Add("n".to_string()),
    Difference::Same("t".to_string())
]);

Trait Implementations

Formats the value using the given formatter. Read more

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.

Converts the given value to a String. Read more
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.