similar 2.3.0

A diff library for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use similar::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",
    );

    let all_changes = diff
        .ops()
        .iter()
        .flat_map(|op| diff.iter_changes(op))
        .collect::<Vec<_>>();
    println!("{}", serde_json::to_string_pretty(&all_changes).unwrap());
}