Debian Codegraph @

tests/integration_test.rs

raw symbols SCIP
1 use daft::{Diffable, Leaf};
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{
3 collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::{BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#, BTreeSetrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/BTreeSet#},
4 fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#,
5 };
6 use uuidrust-analyzer cargo uuid 1.12.1 crate/::Uuidrust-analyzer cargo uuid 1.12.1 Uuid#;
7
8 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Diffable)]
9 enum SomeEnumrust-analyzer cargo daft-derive 0.1.5 SomeEnum# {
10 Arust-analyzer cargo daft-derive 0.1.5 SomeEnum#A#,
11 Brust-analyzer cargo daft-derive 0.1.5 SomeEnum#B#,
12 Crust-analyzer cargo daft-derive 0.1.5 SomeEnum#C#(u32),
13 }
14
15 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Diffable)]
16 struct SomeStructrust-analyzer cargo daft-derive 0.1.5 SomeStruct# {
17 arust-analyzer cargo daft-derive 0.1.5 SomeStruct#a.: i32,
18 }
19
20 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Diffable)]
21 struct Largerust-analyzer cargo daft-derive 0.1.5 Large# {
22 arust-analyzer cargo daft-derive 0.1.5 Large#a.: i32,
23 brust-analyzer cargo daft-derive 0.1.5 Large#b.: SomeEnumrust-analyzer cargo daft-derive 0.1.5 SomeEnum#,
24 crust-analyzer cargo daft-derive 0.1.5 Large#c.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Uuidrust-analyzer cargo uuid 1.12.1 Uuid#, BTreeSetrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/BTreeSet#<usize>>,
25 drust-analyzer cargo daft-derive 0.1.5 Large#d.: SomeStructrust-analyzer cargo daft-derive 0.1.5 SomeStruct#,
26 }
27
28 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Diffable)]
29 struct TupleStructrust-analyzer cargo daft-derive 0.1.5 TupleStruct#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
30
31 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
32 fn test_basicrust-analyzer cargo daft-derive 0.1.5 test_basic().() {
33 let a = SomeEnumrust-analyzer cargo daft-derive 0.1.5 SomeEnum#::Arust-analyzer cargo daft-derive 0.1.5 SomeEnum#A#;
34 let b = SomeEnumrust-analyzer cargo daft-derive 0.1.5 SomeEnum#::Brust-analyzer cargo daft-derive 0.1.5 SomeEnum#B#;
35
36 // Enums are just `Leaf`s. We don't try to walk them. User code can do that
37 // as necessary.
38 let diff = a.diff(&b);
39 let expected = Leaf { before: &SomeEnumrust-analyzer cargo daft-derive 0.1.5 SomeEnum#::Arust-analyzer cargo daft-derive 0.1.5 SomeEnum#A#, after: &SomeEnumrust-analyzer cargo daft-derive 0.1.5 SomeEnum#::Brust-analyzer cargo daft-derive 0.1.5 SomeEnum#B# };
40 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff, expected);
41
42 let a = SomeStructrust-analyzer cargo daft-derive 0.1.5 SomeStruct# { arust-analyzer cargo daft-derive 0.1.5 SomeStruct#a.: 0 };
43 let b = SomeStructrust-analyzer cargo daft-derive 0.1.5 SomeStruct# { arust-analyzer cargo daft-derive 0.1.5 SomeStruct#a.: 1 };
44 let diff = a.diff(&b);
45 let expected = SomeStructDiff { a: Leaf { before: &0, after: &1 } };
46 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff, expected);
47
48 let shared_id = Uuidrust-analyzer cargo uuid 1.12.1 Uuid#::new_v4rust-analyzer cargo uuid 1.12.1 v4/impl#[Uuid]new_v4().();
49 let c1: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<Uuidrust-analyzer cargo uuid 1.12.1 Uuid#, BTreeSetrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/BTreeSet#<usize>> =
50 [(shared_id, [1, 2, 3, 4, 5].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().())]
51 .into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().()
52 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
53 let mut c2 = c1.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`][Clone]clone().();
54 c2.get_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get_mut().(&shared_id).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/impl#[`BTreeSet<T, A>`]remove().(&3);
55 c2.get_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]get_mut().(&shared_id).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/set/impl#[`BTreeSet<T, A>`]insert().(6);
56 c2.insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(Uuidrust-analyzer cargo uuid 1.12.1 Uuid#::new_v4rust-analyzer cargo uuid 1.12.1 v4/impl#[Uuid]new_v4().(), [9].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().());
57 let a = Largerust-analyzer cargo daft-derive 0.1.5 Large# { arust-analyzer cargo daft-derive 0.1.5 Large#a.: 0, brust-analyzer cargo daft-derive 0.1.5 Large#b.: SomeEnumrust-analyzer cargo daft-derive 0.1.5 SomeEnum#::Crust-analyzer cargo daft-derive 0.1.5 SomeEnum#C#(4), crust-analyzer cargo daft-derive 0.1.5 Large#c.: c1, drust-analyzer cargo daft-derive 0.1.5 Large#d.: SomeStructrust-analyzer cargo daft-derive 0.1.5 SomeStruct# { arust-analyzer cargo daft-derive 0.1.5 SomeStruct#a.: 0 } };
58 let b = Largerust-analyzer cargo daft-derive 0.1.5 Large# { arust-analyzer cargo daft-derive 0.1.5 Large#a.: 0, brust-analyzer cargo daft-derive 0.1.5 Large#b.: SomeEnumrust-analyzer cargo daft-derive 0.1.5 SomeEnum#::Brust-analyzer cargo daft-derive 0.1.5 SomeEnum#B#, crust-analyzer cargo daft-derive 0.1.5 Large#c.: c2, drust-analyzer cargo daft-derive 0.1.5 Large#d.: SomeStructrust-analyzer cargo daft-derive 0.1.5 SomeStruct# { arust-analyzer cargo daft-derive 0.1.5 SomeStruct#a.: 1 } };
59 let diff = a.diff(&b);
60 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{diff:#?}");
61
62 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.a.before, diff.a.after);
63 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.b.before, &SomeEnumrust-analyzer cargo daft-derive 0.1.5 SomeEnum#::Crust-analyzer cargo daft-derive 0.1.5 SomeEnum#C#(4));
64 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.b.after, &SomeEnumrust-analyzer cargo daft-derive 0.1.5 SomeEnum#::Brust-analyzer cargo daft-derive 0.1.5 SomeEnum#B#);
65 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.c.unchanged().count(), 0);
66 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.c.added.len(), 1);
67 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.c.removed.len(), 0);
68 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.c.modified().count(), 1);
69
70 let set_diff = &diff.c.modified_diff().next().unwrap().1;
71 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(set_diff.common, [&1, &2, &4, &5].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().());
72 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(set_diff.added, [&6].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().());
73 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(set_diff.removed, [&3].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().());
74
75 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.d.a.before, &0);
76 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.d.a.after, &1);
77
78 let a = TupleStructrust-analyzer cargo daft-derive 0.1.5 TupleStruct#("oxide".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
79 let b = TupleStructrust-analyzer cargo daft-derive 0.1.5 TupleStruct#("computer company".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
80 let diff = a.diff(&b);
81 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.0.before, &"oxide".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
82 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.0.after, &"computer company".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
83 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{diff:#?}");
84 }
85
86 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
87 fn test_enum_with_genericsrust-analyzer cargo daft-derive 0.1.5 test_enum_with_generics().() {
88 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Diffable)]
89 enum EnumWithGenericsrust-analyzer cargo daft-derive 0.1.5 EnumWithGenerics#<'a, T, U> {
90 Arust-analyzer cargo daft-derive 0.1.5 EnumWithGenerics#A#(T),
91 Brust-analyzer cargo daft-derive 0.1.5 EnumWithGenerics#B#(&'a U),
92 }
93
94 let x = 5usize;
95 let y = 5u8;
96 let a = EnumWithGenericsrust-analyzer cargo daft-derive 0.1.5 EnumWithGenerics#::Arust-analyzer cargo daft-derive 0.1.5 EnumWithGenerics#A#(x);
97 let b = EnumWithGenericsrust-analyzer cargo daft-derive 0.1.5 EnumWithGenerics#::Brust-analyzer cargo daft-derive 0.1.5 EnumWithGenerics#B#(&y);
98 let diff = a.diff(&b);
99 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Leaf { before: &a, after: &b }, diff);
100 }
101
102 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
103 fn test_struct_with_genericsrust-analyzer cargo daft-derive 0.1.5 test_struct_with_generics().() {
104 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Diffable)]
105 struct StructWithGenericsrust-analyzer cargo daft-derive 0.1.5 StructWithGenerics#<'d, 'e, T, U>
106 where
107 T: Diffable + 'd,
108 U: Diffable + 'e,
109 {
110 brust-analyzer cargo daft-derive 0.1.5 StructWithGenerics#b.: usize,
111 crust-analyzer cargo daft-derive 0.1.5 StructWithGenerics#c.: &'d T,
112 drust-analyzer cargo daft-derive 0.1.5 StructWithGenerics#d.: &'e U,
113 }
114
115 let x = StructWithGenericsrust-analyzer cargo daft-derive 0.1.5 StructWithGenerics# { brust-analyzer cargo daft-derive 0.1.5 StructWithGenerics#b.: 6, crust-analyzer cargo daft-derive 0.1.5 StructWithGenerics#c.: &5, drust-analyzer cargo daft-derive 0.1.5 StructWithGenerics#d.: &6 };
116 let y = StructWithGenericsrust-analyzer cargo daft-derive 0.1.5 StructWithGenerics# { brust-analyzer cargo daft-derive 0.1.5 StructWithGenerics#b.: 7, crust-analyzer cargo daft-derive 0.1.5 StructWithGenerics#c.: &5, drust-analyzer cargo daft-derive 0.1.5 StructWithGenerics#d.: &7 };
117 let diff = x.diff(&y);
118
119 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.b, Leaf { before: &6, after: &7 });
120 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.c, Leaf { before: &5, after: &5 });
121 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.d, Leaf { before: &6, after: &7 });
122 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{diff:?}");
123
124 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Diffable)]
125 struct Srust-analyzer cargo daft-derive 0.1.5 S#<'a, T, U>
126 where
127 T: Diffable + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + 'a,
128 U: Diffable + 'a,
129 {
130 arust-analyzer cargo daft-derive 0.1.5 S#a.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<usize, T>,
131 brust-analyzer cargo daft-derive 0.1.5 S#b.: usize,
132 crust-analyzer cargo daft-derive 0.1.5 S#c.: &'a U,
133 drust-analyzer cargo daft-derive 0.1.5 S#d.: &'a str,
134 }
135
136 let x = Srust-analyzer cargo daft-derive 0.1.5 S# {
137 arust-analyzer cargo daft-derive 0.1.5 S#a.: [(5, 2usize)].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
138 brust-analyzer cargo daft-derive 0.1.5 S#b.: 5,
139 crust-analyzer cargo daft-derive 0.1.5 S#c.: &6usize,
140 drust-analyzer cargo daft-derive 0.1.5 S#d.: "hello",
141 };
142 let y = Srust-analyzer cargo daft-derive 0.1.5 S# {
143 arust-analyzer cargo daft-derive 0.1.5 S#a.: [(5, 1usize)].into_iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/iter/impl#[`[T; N]`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
144 brust-analyzer cargo daft-derive 0.1.5 S#b.: 5,
145 crust-analyzer cargo daft-derive 0.1.5 S#c.: &6usize,
146 drust-analyzer cargo daft-derive 0.1.5 S#d.: "world",
147 };
148 let diff = x.diff(&y);
149
150 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.a.unchanged().count(), 0);
151 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.a.modified().count(), 1);
152 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.a.added.len(), 0);
153 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.a.removed.len(), 0);
154 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.b.before, diff.b.after);
155 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.c.before, diff.c.after);
156 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.d.before, "hello");
157 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(diff.d.after, "world");
158
159 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{diff:#?}");
160 }
161
162 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
163 fn diff_pair_lifetimesrust-analyzer cargo daft-derive 0.1.5 diff_pair_lifetimes().() {
164 // Complex type to ensure lifetimes are correct.
165 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Diffable)]
166 struct Innerrust-analyzer cargo daft-derive 0.1.5 Inner# {
167 arust-analyzer cargo daft-derive 0.1.5 Inner#a.: u32,
168 brust-analyzer cargo daft-derive 0.1.5 Inner#b.: &'static str,
169 }
170
171 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Diffable)]
172 struct Outerrust-analyzer cargo daft-derive 0.1.5 Outer# {
173 #[daft(leaf)]
174 innerrust-analyzer cargo daft-derive 0.1.5 Outer#inner.: Innerrust-analyzer cargo daft-derive 0.1.5 Inner#,
175 }
176
177 let owned: Leaf<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = {
178 let before = Outerrust-analyzer cargo daft-derive 0.1.5 Outer# { innerrust-analyzer cargo daft-derive 0.1.5 Outer#inner.: Innerrust-analyzer cargo daft-derive 0.1.5 Inner# { arust-analyzer cargo daft-derive 0.1.5 Inner#a.: 5, brust-analyzer cargo daft-derive 0.1.5 Inner#b.: "hello" } };
179 let after = Outerrust-analyzer cargo daft-derive 0.1.5 Outer# { innerrust-analyzer cargo daft-derive 0.1.5 Outer#inner.: Innerrust-analyzer cargo daft-derive 0.1.5 Inner# { arust-analyzer cargo daft-derive 0.1.5 Inner#a.: 6, brust-analyzer cargo daft-derive 0.1.5 Inner#b.: "world" } };
180
181 let diff = before.diff(&after);
182 let inner_diff = {
183 let inner: Leaf<&Innerrust-analyzer cargo daft-derive 0.1.5 Inner#> = diff.inner;
184 // Ensure that inner.diff_pair outlives inner.
185 inner.diff_pair()
186 };
187
188 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().inner_diff.a.before, 5);
189 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#deref().inner_diff.a.after, 6);
190 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(inner_diff.b.before, "hello");
191 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(inner_diff.b.after, "world");
192
193 // The return value of this will outlive before and after as well.
194 inner_diff.b.map(str::to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().)
195 };
196
197 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(owned.before, "hello");
198 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(owned.after, "world");
199 }