| 736 | a.diff(&b, PathBuilder::default(), &mut patches); |
| 737 | |
| 738 | assert_eq!(patches.len(), 1); |
| 739 | |
| 740 | for patch in patches.iter() { |
| 741 | let patch = StructDiff::patch_event(patch).unwrap(); |
| 742 | |
| 743 | assert!(matches!(patch, StructDiffPatch::A(a) if a == 0.5)); |
| 744 | |
| 745 | b.apply(patch); |
| 746 | } |
| 747 | |
| 748 | assert_eq!(a, b); |
| 749 | } |
| 750 | |
| 751 | #[derive(Debug, Clone, Diff, Patch, PartialEq)] |
| 752 | enum DiffingExample { |
| 753 | Unit, |
| 754 | Tuple(f32, f32), |
| 755 | Struct { a: f32, b: f32 }, |
| 756 | } |
| 757 | |
| 758 | #[test] |
| 759 | fn test_enum_diff() { |
| 760 | let mut baseline = DiffingExample::Tuple(1.0, 0.0); |
| 761 | let value = DiffingExample::Tuple(1.0, 1.0); |
| 762 | |