#diff #lcs #slice #string

diff

An LCS based slice and string diffing implementation

12 releases

0.1.11 Nov 16, 2017
0.1.10 Mar 2, 2017
0.1.9 Feb 4, 2016
0.1.8 Dec 26, 2015
0.1.4 Jul 27, 2015
Download history 14671/week @ 2019-04-27 14723/week @ 2019-05-04 15503/week @ 2019-05-11 17375/week @ 2019-05-18 18675/week @ 2019-05-25 20877/week @ 2019-06-01 20392/week @ 2019-06-08 23770/week @ 2019-06-15 21025/week @ 2019-06-22 14299/week @ 2019-06-29 14001/week @ 2019-07-06 11997/week @ 2019-07-13 12763/week @ 2019-07-20 13405/week @ 2019-07-27 13374/week @ 2019-08-03

67,186 downloads per month
Used in 261 crates (37 directly)

MIT/Apache

9KB
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