Updated readme
This commit is contained in:
parent
fe73d46799
commit
b088bdd9dc
1 changed files with 25 additions and 10 deletions
35
README.md
35
README.md
|
|
@ -14,19 +14,34 @@ It's intended to be replacement for the popular but unmaintained
|
||||||
[difference] crate.
|
[difference] crate.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use similar::algorithms::Algorithm;
|
use similar::text::{ChangeTag, TextDiff};
|
||||||
use similar::text::unified_diff;
|
|
||||||
|
|
||||||
let udiff = unified_diff(
|
fn main() {
|
||||||
Algorithm::Patience,
|
let diff = TextDiff::from_lines(
|
||||||
old_text,
|
"Hello World\nThis is the second line.\nThis is the third.",
|
||||||
new_text,
|
"Hallo Welt\nThis is the second line.\nThis is life.\nMoar and more",
|
||||||
3,
|
);
|
||||||
Some(("old.txt", "new.text"))
|
|
||||||
);
|
for op in diff.ops() {
|
||||||
println!("{}", udiff);
|
for change in diff.iter_changes(op) {
|
||||||
|
let sign = match change.tag() {
|
||||||
|
ChangeTag::Delete => "-",
|
||||||
|
ChangeTag::Insert => "+",
|
||||||
|
ChangeTag::Equal => " ",
|
||||||
|
};
|
||||||
|
print!("{}{}", sign, change);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## What's in the box?
|
||||||
|
|
||||||
|
* Myer's diff
|
||||||
|
* Patience diff
|
||||||
|
* Line, word, character and grapheme level diffing
|
||||||
|
* Unified diff generation
|
||||||
|
|
||||||
## License and Links
|
## License and Links
|
||||||
|
|
||||||
- [Documentation](https://docs.rs/similar/)
|
- [Documentation](https://docs.rs/similar/)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue