Added serde example
This commit is contained in:
parent
4a81e573c2
commit
11d18ca26b
2 changed files with 19 additions and 0 deletions
|
|
@ -63,5 +63,9 @@ required-features = ["text"]
|
|||
name = "large"
|
||||
required-features = ["text"]
|
||||
|
||||
[[example]]
|
||||
name = "serde"
|
||||
required-features = ["text", "serde"]
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
|
|
|||
15
examples/serde.rs
Normal file
15
examples/serde.rs
Normal file
|
|
@ -0,0 +1,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());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue