Crate difference

Source
Expand description

§Functions to find the difference between two texts (strings). Usage

Add the following to your Cargo.toml:

[dependencies]
difference = "2.0"

Now you can use the crate in your code

extern crate difference;

§Examples

See Examples.md for more examples.

use difference::{Difference, Changeset};

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())
]);

Macros§

  • Assert the difference between two strings. Works like diff, but takes a fourth parameter that is the expected edit distance (e.g. 0 if you want to test for equality).

Structs§

  • The information about a full changeset

Enums§

  • Defines the contents of a changeset Changesets will be delivered in order of appearance in the original string Sequences of the same kind will be grouped into one Difference

Functions§

  • diffDeprecated
    This function is deprecated, please use Changeset::new instead
  • print_diffDeprecated
    This function is deprecated, Changeset now implements the Display trait instead