#diff #slice #lcs #string

diff

An LCS based slice and string diffing implementation

13 releases

Uses old Rust 2015

0.1.12 Dec 17, 2019
0.1.11 Nov 16, 2017
0.1.10 Mar 2, 2017
0.1.9 Feb 4, 2016
0.1.4 Jul 27, 2015

#80 in Text processing

Download history 81829/week @ 2021-08-11 81982/week @ 2021-08-18 91530/week @ 2021-08-25 75658/week @ 2021-09-01 103328/week @ 2021-09-08 106043/week @ 2021-09-15 104805/week @ 2021-09-22 105129/week @ 2021-09-29 130127/week @ 2021-10-06 135377/week @ 2021-10-13 114134/week @ 2021-10-20 124550/week @ 2021-10-27 123167/week @ 2021-11-03 108556/week @ 2021-11-10 114221/week @ 2021-11-17 88913/week @ 2021-11-24

458,982 downloads per month
Used in 884 crates (72 directly)

MIT/Apache

11KB
102 lines

diff.rs

An LCS based slice and string diffing implementation.

Example

extern crate diff;

fn main() {
    let left = "foo\nbar\nbaz\nquux";
    let right = "foo\nbaz\nbar\nquux";

    for diff in diff::lines(left, right) {
        match diff {
            diff::Result::Left(l)    => println!("-{}", l),
            diff::Result::Both(l, _) => println!(" {}", l),
            diff::Result::Right(r)   => println!("+{}", r)
        }
    }
}

prints

 foo
-bar
 baz
+bar
 quux

License

diff is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE, and LICENSE-MIT for details.

No runtime deps