Files
novem/examples/similar_demo.rs

18 lines
501 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);
}
}