Debian Codegraph @

tests/123_enum_representation.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#, 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#};
2
3 use ronrust-analyzer cargo ron 0.12.0 crate/::{derust-analyzer cargo ron 0.12.0 de/::from_strrust-analyzer cargo ron 0.12.0 de/from_str()., serrust-analyzer cargo ron 0.12.0 ser/::to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().};
4 use serderust-analyzer cargo serde 1.0.228 crate/::{Deserializerust-analyzer cargo serde_core 1.0.228 de/Deserialize#, Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#};
5
6 #[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:)]
7 struct Unitrust-analyzer cargo ron 0.12.0 Unit#;
8
9 #[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:)]
10 struct Tuplerust-analyzer cargo ron 0.12.0 Tuple#(u8, u8);
11
12 #[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:)]
13 enum Innerrust-analyzer cargo ron 0.12.0 Inner# {
14 Foorust-analyzer cargo ron 0.12.0 Inner#Foo#,
15 Barrust-analyzer cargo ron 0.12.0 Inner#Bar#,
16 }
17
18 #[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:)]
19 enum EnumStructExternallyrust-analyzer cargo ron 0.12.0 EnumStructExternally# {
20 VariantArust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA# {
21 foorust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#foo.: u32,
22 barrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#bar.: Unitrust-analyzer cargo ron 0.12.0 Unit#,
23 #[serde(with = "ByteStr")]
24 bazrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#baz.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>,
25 differentrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#different.: Tuplerust-analyzer cargo ron 0.12.0 Tuple#,
26 },
27 VariantBrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB# {
28 foorust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#foo.: u32,
29 barrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#bar.: Unitrust-analyzer cargo ron 0.12.0 Unit#,
30 #[serde(with = "ByteStr")]
31 bazrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#baz.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>,
32 },
33 }
34
35 #[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:)]
36 #[serde(tag = "type")]
37 enum EnumStructInternallyrust-analyzer cargo ron 0.12.0 EnumStructInternally# {
38 VariantArust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA# { foorust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#foo.: u32, barrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#bar.: u32, differentrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#different.: u32 },
39 VariantBrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB#foo.: u32, barrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB#bar.: u32 },
40 }
41
42 #[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:)]
43 #[serde(tag = "type", content = "content")]
44 enum EnumStructAdjacentlyrust-analyzer cargo ron 0.12.0 EnumStructAdjacently# {
45 VariantArust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA# { foorust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#foo.: f64, barrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#bar.: (), differentrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#different.: Innerrust-analyzer cargo ron 0.12.0 Inner# },
46 VariantBrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB#foo.: f64, barrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB#bar.: () },
47 }
48
49 #[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:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Serializerust-analyzer cargo serde_derive 1.0.228 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.228 Deserialize:)]
50 #[serde(untagged)]
51 enum EnumStructUntaggedrust-analyzer cargo ron 0.12.0 EnumStructUntagged# {
52 VariantArust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA# { foorust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#foo.: u32, barrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#bar.: u32, differentrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#different.: u32 },
53 VariantBrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB#foo.: u32, barrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB#bar.: u32 },
54 }
55
56 fn test_serrust-analyzer cargo ron 0.12.0 test_ser().<T: Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize#>(value: &T, expected: &str) {
57 let actual = to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(value).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to serialize");
58 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(actual, expected);
59 }
60
61 fn test_derust-analyzer cargo ron 0.12.0 test_de().<T>(s: &str, expected: T)
62 where
63 T: for<'a> Deserializerust-analyzer cargo serde_core 1.0.228 de/Deserialize#<'a> + Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#,
64 {
65 let actual: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, _> = from_strrust-analyzer cargo ron 0.12.0 de/from_str().(s);
66 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(actual, Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(expected));
67 }
68
69 fn test_roundtriprust-analyzer cargo ron 0.12.0 test_roundtrip().<T>(value: T)
70 where
71 T: Serializerust-analyzer cargo serde_core 1.0.228 ser/Serialize# + for<'a> Deserializerust-analyzer cargo serde_core 1.0.228 de/Deserialize#<'a> + Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#,
72 {
73 let s = to_stringrust-analyzer cargo ron 0.12.0 ser/to_string().(&value).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Failed to serialize");
74 let actual: Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, _> = from_strrust-analyzer cargo ron 0.12.0 de/from_str().(&s);
75 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(actual, Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(value));
76 }
77
78 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
79 fn test_externally_a_serrust-analyzer cargo ron 0.12.0 test_externally_a_ser().() {
80 let v = EnumStructExternallyrust-analyzer cargo ron 0.12.0 EnumStructExternally#::VariantArust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA# {
81 foorust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#foo.: 1,
82 barrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#bar.: Unitrust-analyzer cargo ron 0.12.0 Unit#,
83 bazrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#baz.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![b'a'],
84 differentrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#different.: Tuplerust-analyzer cargo ron 0.12.0 Tuple#(2, 3),
85 };
86 let e = "VariantA(foo:1,bar:(),baz:b\"a\",different:(2,3))";
87 test_serrust-analyzer cargo ron 0.12.0 test_ser().(&v, e);
88 }
89
90 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
91 fn test_externally_b_serrust-analyzer cargo ron 0.12.0 test_externally_b_ser().() {
92 let v = EnumStructExternallyrust-analyzer cargo ron 0.12.0 EnumStructExternally#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB# {
93 foorust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#foo.: 1,
94 barrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#bar.: Unitrust-analyzer cargo ron 0.12.0 Unit#,
95 bazrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#baz.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![b'a'],
96 };
97 let e = "VariantB(foo:1,bar:(),baz:b\"a\")";
98 test_serrust-analyzer cargo ron 0.12.0 test_ser().(&v, e);
99 }
100
101 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
102 fn test_internally_a_serrust-analyzer cargo ron 0.12.0 test_internally_a_ser().() {
103 let v = EnumStructInternallyrust-analyzer cargo ron 0.12.0 EnumStructInternally#::VariantArust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA# {
104 foorust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#foo.: 1,
105 barrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#bar.: 2,
106 differentrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#different.: 3,
107 };
108 let e = "(type:\"VariantA\",foo:1,bar:2,different:3)";
109 test_serrust-analyzer cargo ron 0.12.0 test_ser().(&v, e);
110 }
111
112 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
113 fn test_internally_b_serrust-analyzer cargo ron 0.12.0 test_internally_b_ser().() {
114 let v = EnumStructInternallyrust-analyzer cargo ron 0.12.0 EnumStructInternally#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB#foo.: 1, barrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB#bar.: 2 };
115 let e = "(type:\"VariantB\",foo:1,bar:2)";
116 test_serrust-analyzer cargo ron 0.12.0 test_ser().(&v, e);
117 }
118
119 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
120 fn test_adjacently_a_serrust-analyzer cargo ron 0.12.0 test_adjacently_a_ser().() {
121 let v = EnumStructAdjacentlyrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#::VariantArust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA# {
122 foorust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#foo.: 1.0,
123 barrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#bar.: (),
124 differentrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#different.: Innerrust-analyzer cargo ron 0.12.0 Inner#::Foorust-analyzer cargo ron 0.12.0 Inner#Foo#,
125 };
126 let e = "(type:VariantA,content:(foo:1.0,bar:(),different:Foo))";
127 test_serrust-analyzer cargo ron 0.12.0 test_ser().(&v, e);
128 }
129
130 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
131 fn test_adjacently_b_serrust-analyzer cargo ron 0.12.0 test_adjacently_b_ser().() {
132 let v = EnumStructAdjacentlyrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB#foo.: 1.0, barrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB#bar.: () };
133 let e = "(type:VariantB,content:(foo:1.0,bar:()))";
134 test_serrust-analyzer cargo ron 0.12.0 test_ser().(&v, e);
135 }
136
137 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
138 fn test_untagged_a_serrust-analyzer cargo ron 0.12.0 test_untagged_a_ser().() {
139 let v = EnumStructUntaggedrust-analyzer cargo ron 0.12.0 EnumStructUntagged#::VariantArust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA# {
140 foorust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#foo.: 1,
141 barrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#bar.: 2,
142 differentrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#different.: 3,
143 };
144 let e = "(foo:1,bar:2,different:3)";
145 test_serrust-analyzer cargo ron 0.12.0 test_ser().(&v, e);
146 }
147
148 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
149 fn test_untagged_b_serrust-analyzer cargo ron 0.12.0 test_untagged_b_ser().() {
150 let v = EnumStructUntaggedrust-analyzer cargo ron 0.12.0 EnumStructUntagged#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB#foo.: 1, barrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB#bar.: 2 };
151 let e = "(foo:1,bar:2)";
152 test_serrust-analyzer cargo ron 0.12.0 test_ser().(&v, e);
153 }
154
155 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
156 fn test_externally_a_derust-analyzer cargo ron 0.12.0 test_externally_a_de().() {
157 let s = "VariantA(foo:1,bar:Unit,baz:b\"a\",different:Tuple(2,3))";
158 let e = EnumStructExternallyrust-analyzer cargo ron 0.12.0 EnumStructExternally#::VariantArust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA# {
159 foorust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#foo.: 1,
160 barrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#bar.: Unitrust-analyzer cargo ron 0.12.0 Unit#,
161 bazrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#baz.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![b'a'],
162 differentrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#different.: Tuplerust-analyzer cargo ron 0.12.0 Tuple#(2, 3),
163 };
164 test_derust-analyzer cargo ron 0.12.0 test_de().(s, e);
165 }
166
167 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
168 fn test_externally_b_derust-analyzer cargo ron 0.12.0 test_externally_b_de().() {
169 let s = "VariantB(foo:1,bar:Unit,baz:b\"a\")";
170 let e = EnumStructExternallyrust-analyzer cargo ron 0.12.0 EnumStructExternally#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB# {
171 foorust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#foo.: 1,
172 barrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#bar.: Unitrust-analyzer cargo ron 0.12.0 Unit#,
173 bazrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#baz.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![b'a'],
174 };
175 test_derust-analyzer cargo ron 0.12.0 test_de().(s, e);
176 }
177
178 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
179 fn test_internally_a_derust-analyzer cargo ron 0.12.0 test_internally_a_de().() {
180 let s = "(type:\"VariantA\",foo:1,bar:2,different:3)";
181 let e = EnumStructInternallyrust-analyzer cargo ron 0.12.0 EnumStructInternally#::VariantArust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA# {
182 foorust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#foo.: 1,
183 barrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#bar.: 2,
184 differentrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#different.: 3,
185 };
186 test_derust-analyzer cargo ron 0.12.0 test_de().(s, e);
187 }
188
189 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
190 fn test_internally_b_derust-analyzer cargo ron 0.12.0 test_internally_b_de().() {
191 let s = "(type:\"VariantB\",foo:1,bar:2)";
192 let e = EnumStructInternallyrust-analyzer cargo ron 0.12.0 EnumStructInternally#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB#foo.: 1, barrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB#bar.: 2 };
193 test_derust-analyzer cargo ron 0.12.0 test_de().(s, e);
194 }
195
196 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
197 fn test_adjacently_a_derust-analyzer cargo ron 0.12.0 test_adjacently_a_de().() {
198 let s = "(type:VariantA,content:(foo:1.0,bar:(),different:Foo))";
199 let e = EnumStructAdjacentlyrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#::VariantArust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA# {
200 foorust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#foo.: 1.0,
201 barrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#bar.: (),
202 differentrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#different.: Innerrust-analyzer cargo ron 0.12.0 Inner#::Foorust-analyzer cargo ron 0.12.0 Inner#Foo#,
203 };
204 test_derust-analyzer cargo ron 0.12.0 test_de().(s, e);
205 }
206
207 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
208 fn test_adjacently_b_derust-analyzer cargo ron 0.12.0 test_adjacently_b_de().() {
209 let s = "(type:VariantB,content:(foo:1.0,bar:()))";
210 let e = EnumStructAdjacentlyrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB#foo.: 1.0, barrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB#bar.: () };
211 test_derust-analyzer cargo ron 0.12.0 test_de().(s, e);
212 }
213
214 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
215 fn test_untagged_a_derust-analyzer cargo ron 0.12.0 test_untagged_a_de().() {
216 let s = "(foo:1,bar:2,different:3)";
217 let e = EnumStructUntaggedrust-analyzer cargo ron 0.12.0 EnumStructUntagged#::VariantArust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA# {
218 foorust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#foo.: 1,
219 barrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#bar.: 2,
220 differentrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#different.: 3,
221 };
222 test_derust-analyzer cargo ron 0.12.0 test_de().(s, e);
223 }
224
225 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
226 fn test_untagged_b_derust-analyzer cargo ron 0.12.0 test_untagged_b_de().() {
227 let s = "(foo:1,bar:2)";
228 let e = EnumStructUntaggedrust-analyzer cargo ron 0.12.0 EnumStructUntagged#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB#foo.: 1, barrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB#bar.: 2 };
229 test_derust-analyzer cargo ron 0.12.0 test_de().(s, e);
230 }
231
232 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
233 fn test_externally_a_roundtriprust-analyzer cargo ron 0.12.0 test_externally_a_roundtrip().() {
234 let v = EnumStructExternallyrust-analyzer cargo ron 0.12.0 EnumStructExternally#::VariantArust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA# {
235 foorust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#foo.: 1,
236 barrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#bar.: Unitrust-analyzer cargo ron 0.12.0 Unit#,
237 bazrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#baz.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![b'a'],
238 differentrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantA#different.: Tuplerust-analyzer cargo ron 0.12.0 Tuple#(2, 3),
239 };
240 test_roundtriprust-analyzer cargo ron 0.12.0 test_roundtrip().(v);
241 }
242
243 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
244 fn test_externally_b_roundtriprust-analyzer cargo ron 0.12.0 test_externally_b_roundtrip().() {
245 let v = EnumStructExternallyrust-analyzer cargo ron 0.12.0 EnumStructExternally#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB# {
246 foorust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#foo.: 1,
247 barrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#bar.: Unitrust-analyzer cargo ron 0.12.0 Unit#,
248 bazrust-analyzer cargo ron 0.12.0 EnumStructExternally#VariantB#baz.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![b'a'],
249 };
250 test_roundtriprust-analyzer cargo ron 0.12.0 test_roundtrip().(v);
251 }
252
253 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
254 fn test_internally_a_roundtriprust-analyzer cargo ron 0.12.0 test_internally_a_roundtrip().() {
255 let v = EnumStructInternallyrust-analyzer cargo ron 0.12.0 EnumStructInternally#::VariantArust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA# {
256 foorust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#foo.: 1,
257 barrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#bar.: 2,
258 differentrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantA#different.: 3,
259 };
260 test_roundtriprust-analyzer cargo ron 0.12.0 test_roundtrip().(v);
261 }
262
263 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
264 fn test_internally_b_roundtriprust-analyzer cargo ron 0.12.0 test_internally_b_roundtrip().() {
265 let v = EnumStructInternallyrust-analyzer cargo ron 0.12.0 EnumStructInternally#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB#foo.: 1, barrust-analyzer cargo ron 0.12.0 EnumStructInternally#VariantB#bar.: 2 };
266 test_roundtriprust-analyzer cargo ron 0.12.0 test_roundtrip().(v);
267 }
268
269 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
270 fn test_adjacently_a_roundtriprust-analyzer cargo ron 0.12.0 test_adjacently_a_roundtrip().() {
271 let v = EnumStructAdjacentlyrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#::VariantArust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA# {
272 foorust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#foo.: 1.0,
273 barrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#bar.: (),
274 differentrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantA#different.: Innerrust-analyzer cargo ron 0.12.0 Inner#::Foorust-analyzer cargo ron 0.12.0 Inner#Foo#,
275 };
276 test_roundtriprust-analyzer cargo ron 0.12.0 test_roundtrip().(v);
277 }
278
279 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
280 fn test_adjacently_b_roundtriprust-analyzer cargo ron 0.12.0 test_adjacently_b_roundtrip().() {
281 let v = EnumStructAdjacentlyrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB#foo.: 1.0, barrust-analyzer cargo ron 0.12.0 EnumStructAdjacently#VariantB#bar.: () };
282 test_roundtriprust-analyzer cargo ron 0.12.0 test_roundtrip().(v);
283 }
284
285 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
286 fn test_untagged_a_roundtriprust-analyzer cargo ron 0.12.0 test_untagged_a_roundtrip().() {
287 let v = EnumStructUntaggedrust-analyzer cargo ron 0.12.0 EnumStructUntagged#::VariantArust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA# {
288 foorust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#foo.: 1,
289 barrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#bar.: 2,
290 differentrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantA#different.: 3,
291 };
292 test_roundtriprust-analyzer cargo ron 0.12.0 test_roundtrip().(v);
293 }
294
295 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
296 fn test_untagged_b_roundtriprust-analyzer cargo ron 0.12.0 test_untagged_b_roundtrip().() {
297 let v = EnumStructUntaggedrust-analyzer cargo ron 0.12.0 EnumStructUntagged#::VariantBrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB# { foorust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB#foo.: 1, barrust-analyzer cargo ron 0.12.0 EnumStructUntagged#VariantB#bar.: 2 };
298 test_roundtriprust-analyzer cargo ron 0.12.0 test_roundtrip().(v);
299 }
300
301 enum ByteStrrust-analyzer cargo ron 0.12.0 ByteStr# {}
302
303 impl ByteStrrust-analyzer cargo ron 0.12.0 ByteStr# {
304 fn serializerust-analyzer cargo ron 0.12.0 impl#[ByteStr]serialize().<S: serderust-analyzer cargo serde 1.0.228 crate/::Serializerrust-analyzer cargo serde_core 1.0.228 ser/Serializer#>(data: &[u8], serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.228 ser/Serializer#Error#> {
305 serializer.serialize_bytesrust-analyzer cargo serde_core 1.0.228 ser/Serializer#serialize_bytes().(data)
306 }
307
308 fn deserializerust-analyzer cargo ron 0.12.0 impl#[ByteStr]deserialize().<'de, D: serderust-analyzer cargo serde 1.0.228 crate/::Deserializerrust-analyzer cargo serde_core 1.0.228 de/Deserializer#<'de>>(deserializer: D) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>, D::Errorrust-analyzer cargo serde_core 1.0.228 de/Deserializer#Error#> {
309 struct ByteStrVisitorrust-analyzer cargo ron 0.12.0 ByteStrVisitor#;
310
311 impl<'de> serderust-analyzer cargo serde 1.0.228 crate/::derust-analyzer cargo serde_core 1.0.228 de/::Visitorrust-analyzer cargo serde_core 1.0.228 de/Visitor#<'de> for ByteStrVisitorrust-analyzer cargo ron 0.12.0 ByteStrVisitor# {
312 type Valuerust-analyzer cargo ron 0.12.0 impl#[ByteStrVisitor][`Visitor<'de>`]Value# = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>;
313
314 // GRCOV_EXCL_START
315 fn expectingrust-analyzer cargo ron 0.12.0 impl#[ByteStrVisitor][`Visitor<'de>`]expecting().(&self, fmt: &mut corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
316 fmt.write_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]write_str().("a Rusty byte string")
317 }
318 // GRCOV_EXCL_STOP
319
320 fn visit_bytesrust-analyzer cargo ron 0.12.0 impl#[ByteStrVisitor][`Visitor<'de>`]visit_bytes().<E: serderust-analyzer cargo serde 1.0.228 crate/::derust-analyzer cargo serde_core 1.0.228 de/::Errorrust-analyzer cargo serde_core 1.0.228 de/Error#>(self, bytes: &[u8]) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo ron 0.12.0 impl#[ByteStrVisitor][`Visitor<'de>`]::Valuerust-analyzer cargo serde_core 1.0.228 de/Visitor#Value#, E> {
321 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(bytes.to_vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]to_vec().())
322 }
323 }
324
325 deserializer.deserialize_bytesrust-analyzer cargo serde_core 1.0.228 de/Deserializer#deserialize_bytes().(ByteStrVisitorrust-analyzer cargo ron 0.12.0 ByteStrVisitor#)
326 }
327 }