rustc/vendor/diff
2019-04-29 16:16:11 -07:00
..
benches New upstream version 1.32.0~beta.2+dfsg1 2018-12-16 10:13:16 -08:00
examples New upstream version 1.32.0~beta.2+dfsg1 2018-12-16 10:13:16 -08:00
src New upstream version 1.32.0~beta.2+dfsg1 2018-12-16 10:13:16 -08:00
tests New upstream version 1.32.0~beta.2+dfsg1 2018-12-16 10:13:16 -08:00
.cargo-checksum.json New upstream version 1.33.0+dfsg1 2019-04-29 16:16:11 -07:00
Cargo.toml New upstream version 1.32.0~beta.2+dfsg1 2018-12-16 10:13:16 -08:00
LICENSE-APACHE New upstream version 1.32.0~beta.2+dfsg1 2018-12-16 10:13:16 -08:00
LICENSE-MIT New upstream version 1.32.0~beta.2+dfsg1 2018-12-16 10:13:16 -08:00
README.md New upstream version 1.32.0~beta.2+dfsg1 2018-12-16 10:13:16 -08:00

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.