Fixed example in readme and update lib.rs example
This commit is contained in:
parent
b088bdd9dc
commit
d0a715d7af
2 changed files with 18 additions and 5 deletions
|
|
@ -29,7 +29,7 @@ fn main() {
|
|||
ChangeTag::Insert => "+",
|
||||
ChangeTag::Equal => " ",
|
||||
};
|
||||
print!("{}{}", sign, change);
|
||||
print!("{}{}", sign, change.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
21
src/lib.rs
21
src/lib.rs
|
|
@ -4,10 +4,23 @@
|
|||
//!
|
||||
//! ```rust
|
||||
//! # #[cfg(feature = "text")] {
|
||||
//! use similar::text::TextDiff;
|
||||
//! # let old_text = "";
|
||||
//! # let new_text = "";
|
||||
//! let diff = TextDiff::from_chars("Hello World", "Hallo Welt");
|
||||
//! use similar::text::{ChangeTag, TextDiff};
|
||||
//!
|
||||
//! 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 op in diff.ops() {
|
||||
//! for change in diff.iter_changes(op) {
|
||||
//! let sign = match change.tag() {
|
||||
//! ChangeTag::Delete => "-",
|
||||
//! ChangeTag::Insert => "+",
|
||||
//! ChangeTag::Equal => " ",
|
||||
//! };
|
||||
//! print!("{}{}", sign, change.value());
|
||||
//! }
|
||||
//! }
|
||||
//! # }
|
||||
//! ```
|
||||
//!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue