()
| 55 | |
| 56 | #[test] |
| 57 | fn example() { |
| 58 | let unity: std::collections::HashMap<_, _> = |
| 59 | [(1, 1), (2, 2), (3, 3)].iter().cloned().collect(); |
| 60 | let not_unity: std::collections::HashMap<_, _> = |
| 61 | [(1, 1), (2, 3), (4, 4)].iter().cloned().collect(); |
| 62 | |
| 63 | if let Edit::Change(diff) = unity.diff(¬_unity) { |
| 64 | assert!(diff[&1].is_copy()); |
| 65 | assert_eq!(diff[&2].change().unwrap(), &(&2, &3)); |
| 66 | assert!(diff[&3].is_remove()); |
| 67 | assert_eq!(diff[&4].insert().unwrap(), &4); |
| 68 | } else { |
| 69 | unreachable!() |
| 70 | } |
| 71 | } |
| 72 | } |