18 lines
495 B
Rust
18 lines
495 B
Rust
use similar::{ChangeTag, TextDiff};
|
|
|
|
fn main() {
|
|
let diff = TextDiff::from_lines(
|
|
"Hello World\nThis is the second line.\nThis is the third.",
|
|
"Hallo Welt\nThis is the second line.\nThis is life.\nMoar and more",
|
|
);
|
|
|
|
for change in diff.iter_all_changes() {
|
|
let sign = match change.tag() {
|
|
ChangeTag::Delete => "-",
|
|
ChangeTag::Insert => "+",
|
|
ChangeTag::Equal => " ",
|
|
};
|
|
print!("{}{}", sign, change);
|
|
}
|
|
}
|