#hash-map #diff #subtract

hash_map_diff

比较两个HashMap之间的变化

2个不稳定版本

0.2.0 2022年8月29日
0.1.0 2022年8月23日

#2369 in 算法

Download history 301/week @ 2024-03-11 303/week @ 2024-03-18 381/week @ 2024-03-25 427/week @ 2024-04-01 289/week @ 2024-04-08 492/week @ 2024-04-15 296/week @ 2024-04-22 340/week @ 2024-04-29 313/week @ 2024-05-06 449/week @ 2024-05-13 316/week @ 2024-05-20 241/week @ 2024-05-27 272/week @ 2024-06-03 215/week @ 2024-06-10 177/week @ 2024-06-17 150/week @ 2024-06-24

835每月下载量

MIT许可证

5KB
83

hash_map_diff

这个库旨在计算两个HashMap之间的差异,以查看lhs中哪些键被删除,以及rhs中哪些键接收了新值。

使用示例

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);
}

构建

cargob

测试

cargot

无运行时依赖