diff --git a/README.md b/README.md index 4c2f508..1656312 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ fn main() { ChangeTag::Insert => "+", ChangeTag::Equal => " ", }; - print!("{}{}", sign, change); + print!("{}{}", sign, change.value()); } } } diff --git a/src/lib.rs b/src/lib.rs index 1c33e6c..09ddb3f 100644 --- a/src/lib.rs +++ b/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()); +//! } +//! } //! # } //! ``` //!