#diff #difference #change #assert

bin+lib text-diff

A Rust text diffing and assertion library

2 unstable releases

Uses old Rust 2015

0.4.0 Aug 2, 2015
0.3.0 Jul 10, 2015

#1100 in Text processing

Download history 1795/week @ 2024-07-21 3126/week @ 2024-07-28 3627/week @ 2024-08-04 2180/week @ 2024-08-11 1541/week @ 2024-08-18 5428/week @ 2024-08-25 2906/week @ 2024-09-01 1855/week @ 2024-09-08 2695/week @ 2024-09-15 3537/week @ 2024-09-22 1528/week @ 2024-09-29 2416/week @ 2024-10-06 2795/week @ 2024-10-13 4478/week @ 2024-10-20 1855/week @ 2024-10-27 1890/week @ 2024-11-03

11,128 downloads per month
Used in 7 crates

MIT license

160KB
260 lines

text-diff.rs

A Rust text diffing library.

Documentation

Examples

let (dist, changeset) = diff("test", "tent", "");

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

Usage

Add the following to your Cargo.toml:

[dependencies.text_diff]

git = "https://github.com/johannhof/text-diff.rs.git"

Now you can use the crate in your code

extern crate text_diff;

Using the binary

text-diff can also be used as a command-line application. The best way to install it is using rustle:

curl -sf https://raw.githubusercontent.com/brson/rustle/master/rustle.sh | sh -s -- https://github.com/johannhof/text-diff.rs

Dependencies

~1.5MB
~24K SLoC