3 stable releases
Uses new Rust 2024
| 3.2.0 | Jul 17, 2025 |
|---|---|
| 3.1.0 | Jul 3, 2025 |
| 3.0.0 | Jun 24, 2025 |
#1292 in Text processing
307 downloads per month
Used in 2 crates
(via smart-patcher)
195KB
710 lines
difference_rs
A Rust, updated, text diffing library with built-in diffing assertion.
use difference_rs::Changeset;
let changeset = Changeset::new("test", "tent", "");
assert_eq!(changeset.diffs, vec![
Difference::Same("te".to_string()),
Difference::Rem("s".to_string()),
Difference::Add("n".to_string()),
Difference::Same("t".to_string())
]);

use difference_rs::{Changeset, Difference};
let changeset = Changeset::new_multi(
"https://localhost:8080/path?query=value",
"https://myapi.com/api/path?query=asset",
&["://", "/", "?", "="],
);
assert_eq!(changeset.diffs, vec![
Difference::Same("https://".to_string()),
Difference::Rem("localhost:8080/".to_string()),
Difference::Add("myapi.com/api/".to_string()),
Difference::Same("path?query=".to_string()),
Difference::Rem("value".to_string()),
Difference::Add("asset".to_string()),
]);
![]()
Usage
Add the following to your Cargo.toml:
[dependencies]
difference_rs = "3.2"
If you require serialization of the the Differences, use the feature serde:
This implements
serde::{Serialize, Deserialize}forDifference,Changeset,ChangesetMulti
[dependencies]
difference_rs = { version = "3.2", feature = ["serde"] }
Now you can use the crate in your code
Using the binary
difference_rs can also be used as a command-line application. The best way to install it is using:
$ cargo install --features=bin