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::Insert => "+",
|
||||||
ChangeTag::Equal => " ",
|
ChangeTag::Equal => " ",
|
||||||
};
|
};
|
||||||
print!("{}{}", sign, change);
|
print!("{}{}", sign, change.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
src/lib.rs
21
src/lib.rs
|
|
@ -4,10 +4,23 @@
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! # #[cfg(feature = "text")] {
|
//! # #[cfg(feature = "text")] {
|
||||||
//! use similar::text::TextDiff;
|
//! use similar::text::{ChangeTag, TextDiff};
|
||||||
//! # let old_text = "";
|
//!
|
||||||
//! # let new_text = "";
|
//! let diff = TextDiff::from_lines(
|
||||||
//! let diff = TextDiff::from_chars("Hello World", "Hallo Welt");
|
//! "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