Struct difference::Changeset [] [src]

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

The information about a full changeset

Fields

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

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

The edit distance of the Changeset

Methods

impl Changeset
[src]

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

impl Display for Changeset
[src]

Formats the value using the given formatter.