| 1 |
# diff.rs |
| 2 |
|
| 3 |
> An LCS based slice and string diffing implementation. |
| 4 |
|
| 5 |
## Install |
| 6 |
|
| 7 |
```toml |
| 8 |
[dependencies] |
| 9 |
diff = "0.1" |
| 10 |
``` |
| 11 |
|
| 12 |
## Example |
| 13 |
|
| 14 |
```rust |
| 15 |
extern crate diff; |
| 16 |
|
| 17 |
fn main() { |
| 18 |
let left = "foo\nbar\nbaz\nquux"; |
| 19 |
let right = "foo\nbaz\nbar\nquux"; |
| 20 |
|
| 21 |
for diff in diff::lines(left, right) { |
| 22 |
match diff { |
| 23 |
diff::Result::Left(l) => println!("-{}", l), |
| 24 |
diff::Result::Both(l, _) => println!(" {}", l), |
| 25 |
diff::Result::Right(r) => println!("+{}", r) |
| 26 |
} |
| 27 |
} |
| 28 |
} |
| 29 |
``` |
| 30 |
|
| 31 |
prints |
| 32 |
|
| 33 |
``` |
| 34 |
foo |
| 35 |
-bar |
| 36 |
baz |
| 37 |
+bar |
| 38 |
quux |
| 39 |
``` |
| 40 |
|
| 41 |
## License |
| 42 |
|
| 43 |
`diff` is primarily distributed under the terms of both the MIT license and the |
| 44 |
Apache License (Version 2.0). |
| 45 |
|
| 46 |
See LICENSE-APACHE, and LICENSE-MIT for details. |