#diff #difference #change #assert

dev 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

#1167 in Text processing

Download history 1275/week @ 2024-11-16 1975/week @ 2024-11-23 1544/week @ 2024-11-30 2512/week @ 2024-12-07 1837/week @ 2024-12-14 608/week @ 2024-12-21 2533/week @ 2024-12-28 5664/week @ 2025-01-04 4725/week @ 2025-01-11 5110/week @ 2025-01-18 5632/week @ 2025-01-25 4856/week @ 2025-02-01 3481/week @ 2025-02-08 4096/week @ 2025-02-15 6173/week @ 2025-02-22 5422/week @ 2025-03-01

19,930 downloads per month
Used in 8 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
~25K SLoC