#hash-map #diff #subtract

hash_map_diff

Comparing changes between two HashMaps

2 unstable releases

0.2.0 Aug 29, 2022
0.1.0 Aug 23, 2022

#1 in #subtract

Download history 132/week @ 2024-06-22 53/week @ 2024-06-29 38/week @ 2024-07-06 78/week @ 2024-07-13 100/week @ 2024-07-20 118/week @ 2024-07-27 134/week @ 2024-08-03 149/week @ 2024-08-10 160/week @ 2024-08-17 48/week @ 2024-08-24 52/week @ 2024-08-31 40/week @ 2024-09-07 45/week @ 2024-09-14 147/week @ 2024-09-21 173/week @ 2024-09-28 62/week @ 2024-10-05

432 downloads per month

MIT license

5KB
83 lines

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

No runtime deps