From 058924614a8904c5e68d6ee2c580d7b2140f7aee Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Sun, 24 Jan 2021 02:28:37 +0100 Subject: [PATCH] Added example to readme --- Cargo.toml | 2 +- README.md | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 8865de7..d5bae37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0" description = "A diff library for Rust" repository = "https://github.com/mitsuhiko/similar" -keywords = ["diff", "difference", "udiff", "compare", "changes"] +keywords = ["diff", "difference", "patience", "compare", "changes"] readme = "README.md" [dev-dependencies] diff --git a/README.md b/README.md index 3fa2b60..873afd7 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,20 @@ It provides both low level implementations of Myer's and the Patience diff algorithm as well as high level text diffing utilities (such as the ability to generate unified diffs). +```rust +use similar::algorithms::Algorithm; +use similar::text::unified_diff; + +let unified_diff = unified_diff( + Algorithm::Patience, + old_text, + new_text, + 3, + Some(("old.txt", "new.text")) +); +println!("{}", unified_diff); +``` + ## License and Links - [Documentation](https://docs.rs/similar/)