hash_map_diff

Crates.iohash_map_diff
lib.rshash_map_diff
version0.2.0
sourcesrc
created_at2022-08-23 13:09:42.764516
updated_at2022-08-29 08:17:57.127282
descriptionComparing changes between two HashMaps
homepage
repositoryhttps://github.com/Tesel/hash_map_diff
max_upload_size
id650978
size4,640
(Tesel)

documentation

README

hash_map_diff

This library is intended to compute diff between two hashmaps to see which keys have been removed in lhs, and which ones have received new value in rhs.

Usage example

use hash_map_diff::{hash_map_diff, HashMapDiff};

pub fn main() {
    let lhs = [("unchanged", 1), ("removed", 2), ("changed", 3)].into();
    let rhs = [("unchanged", 1), ("changed", 5), ("added", 4)].into();

    let received_diff = hash_map_diff(&lhs, &rhs);

    let expected_diff = HashMapDiff {
        updated: [(&"changed", &5), (&"added", &4)].into(),
        removed: [(&"removed", &2)].into(),
    };

    assert_eq!(received_diff, expected_diff);
}

Building

cargo b

Testing

cargo t

Commit count: 6

cargo fmt