19 stable releases (5 major)

5.0.0 Mar 27, 2024
4.0.3 Feb 3, 2024
4.0.2 Oct 9, 2021
4.0.0 Feb 2, 2020
0.1.0 Feb 5, 2017

#62 in Algorithms

Download history 41949/week @ 2023-12-23 73128/week @ 2023-12-30 105979/week @ 2024-01-06 105784/week @ 2024-01-13 111368/week @ 2024-01-20 112356/week @ 2024-01-27 129617/week @ 2024-02-03 132684/week @ 2024-02-10 140094/week @ 2024-02-17 153461/week @ 2024-02-24 144545/week @ 2024-03-02 160025/week @ 2024-03-09 156877/week @ 2024-03-16 162966/week @ 2024-03-23 162422/week @ 2024-03-30 135655/week @ 2024-04-06

644,492 downloads per month
Used in 11 crates (7 directly)

MIT/Apache

47KB
1K SLoC

Rust crates.io version

A library to compare arbitrary structured data of the same type, efficiently.

Please see the documentation for more details.

Usage

Add this to your Cargo.toml

[dependencies]
treediff = "4"

lib.rs:

See what's different in arbitrary data structures.

The main diff algorithm. we implement here is less than a screen full of lines, yet it enables a vast amount of applications. It can work with all values implementing the Value trait.

On top of it there is a merge implementation, which can be used to aggregate changes into a target value. It works with Values which implement the Mutable trait.

Usage

Please have a look at the tests for diff and merge.

Also note that you will have to choose the features to build the library with in order to get trait implementations for Value types of common libraries, i.e. cargo build --features=with-serde-json.

Dependencies

~0–2MB
~35K SLoC