2个不稳定版本
0.2.0 | 2022年8月29日 |
---|---|
0.1.0 | 2022年8月23日 |
#2369 in 算法
835每月下载量
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