#diff #lcs #slice #string

diff

An LCS based slice and string diffing implementation

13 releases

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
Download history 14050/week @ 2019-12-02 14274/week @ 2019-12-09 15153/week @ 2019-12-16 11104/week @ 2019-12-23 10274/week @ 2019-12-30 15255/week @ 2020-01-06 15154/week @ 2020-01-13 16234/week @ 2020-01-20 16507/week @ 2020-01-27 15635/week @ 2020-02-03 12406/week @ 2020-02-10 12793/week @ 2020-02-17 14047/week @ 2020-02-24 14653/week @ 2020-03-02 13766/week @ 2020-03-09 14374/week @ 2020-03-16

63,753 downloads per month
Used in 300 crates (51 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