• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use serde::{Deserialize, Serialize};
2 enum Lifetimes<'a> {
3     LifetimeSeq(&'a i32),
4     NoLifetimeSeq(i32),
5     LifetimeMap { a: &'a i32 },
6     NoLifetimeMap { a: i32 },
7 }
8 #[doc(hidden)]
9 #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
10 const _: () = {
11     #[allow(unused_extern_crates, clippy::useless_attribute)]
12     extern crate serde as _serde;
13     #[automatically_derived]
14     impl<'a> _serde::Serialize for Lifetimes<'a> {
serialize<__S>( &self, __serializer: __S, ) -> _serde::__private::Result<__S::Ok, __S::Error> where __S: _serde::Serializer,15         fn serialize<__S>(
16             &self,
17             __serializer: __S,
18         ) -> _serde::__private::Result<__S::Ok, __S::Error>
19         where
20             __S: _serde::Serializer,
21         {
22             match *self {
23                 Lifetimes::LifetimeSeq(ref __field0) => {
24                     _serde::Serializer::serialize_newtype_variant(
25                         __serializer,
26                         "Lifetimes",
27                         0u32,
28                         "LifetimeSeq",
29                         __field0,
30                     )
31                 }
32                 Lifetimes::NoLifetimeSeq(ref __field0) => {
33                     _serde::Serializer::serialize_newtype_variant(
34                         __serializer,
35                         "Lifetimes",
36                         1u32,
37                         "NoLifetimeSeq",
38                         __field0,
39                     )
40                 }
41                 Lifetimes::LifetimeMap { ref a } => {
42                     let mut __serde_state = match _serde::Serializer::serialize_struct_variant(
43                         __serializer,
44                         "Lifetimes",
45                         2u32,
46                         "LifetimeMap",
47                         0 + 1,
48                     ) {
49                         _serde::__private::Ok(__val) => __val,
50                         _serde::__private::Err(__err) => {
51                             return _serde::__private::Err(__err);
52                         }
53                     };
54                     match _serde::ser::SerializeStructVariant::serialize_field(
55                         &mut __serde_state,
56                         "a",
57                         a,
58                     ) {
59                         _serde::__private::Ok(__val) => __val,
60                         _serde::__private::Err(__err) => {
61                             return _serde::__private::Err(__err);
62                         }
63                     };
64                     _serde::ser::SerializeStructVariant::end(__serde_state)
65                 }
66                 Lifetimes::NoLifetimeMap { ref a } => {
67                     let mut __serde_state = match _serde::Serializer::serialize_struct_variant(
68                         __serializer,
69                         "Lifetimes",
70                         3u32,
71                         "NoLifetimeMap",
72                         0 + 1,
73                     ) {
74                         _serde::__private::Ok(__val) => __val,
75                         _serde::__private::Err(__err) => {
76                             return _serde::__private::Err(__err);
77                         }
78                     };
79                     match _serde::ser::SerializeStructVariant::serialize_field(
80                         &mut __serde_state,
81                         "a",
82                         a,
83                     ) {
84                         _serde::__private::Ok(__val) => __val,
85                         _serde::__private::Err(__err) => {
86                             return _serde::__private::Err(__err);
87                         }
88                     };
89                     _serde::ser::SerializeStructVariant::end(__serde_state)
90                 }
91             }
92         }
93     }
94 };
95 #[doc(hidden)]
96 #[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
97 const _: () = {
98     #[allow(unused_extern_crates, clippy::useless_attribute)]
99     extern crate serde as _serde;
100     #[automatically_derived]
101     impl<'de, 'a> _serde::Deserialize<'de> for Lifetimes<'a> {
deserialize<__D>(__deserializer: __D) -> _serde::__private::Result<Self, __D::Error> where __D: _serde::Deserializer<'de>,102         fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result<Self, __D::Error>
103         where
104             __D: _serde::Deserializer<'de>,
105         {
106             #[allow(non_camel_case_types)]
107             enum __Field {
108                 __field0,
109                 __field1,
110                 __field2,
111                 __field3,
112             }
113             struct __FieldVisitor;
114             impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
115                 type Value = __Field;
116                 fn expecting(
117                     &self,
118                     __formatter: &mut _serde::__private::Formatter,
119                 ) -> _serde::__private::fmt::Result {
120                     _serde::__private::Formatter::write_str(__formatter, "variant identifier")
121                 }
122                 fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result<Self::Value, __E>
123                 where
124                     __E: _serde::de::Error,
125                 {
126                     match __value {
127                         0u64 => _serde::__private::Ok(__Field::__field0),
128                         1u64 => _serde::__private::Ok(__Field::__field1),
129                         2u64 => _serde::__private::Ok(__Field::__field2),
130                         3u64 => _serde::__private::Ok(__Field::__field3),
131                         _ => _serde::__private::Err(_serde::de::Error::invalid_value(
132                             _serde::de::Unexpected::Unsigned(__value),
133                             &"variant index 0 <= i < 4",
134                         )),
135                     }
136                 }
137                 fn visit_str<__E>(
138                     self,
139                     __value: &str,
140                 ) -> _serde::__private::Result<Self::Value, __E>
141                 where
142                     __E: _serde::de::Error,
143                 {
144                     match __value {
145                         "LifetimeSeq" => _serde::__private::Ok(__Field::__field0),
146                         "NoLifetimeSeq" => _serde::__private::Ok(__Field::__field1),
147                         "LifetimeMap" => _serde::__private::Ok(__Field::__field2),
148                         "NoLifetimeMap" => _serde::__private::Ok(__Field::__field3),
149                         _ => _serde::__private::Err(_serde::de::Error::unknown_variant(
150                             __value, VARIANTS,
151                         )),
152                     }
153                 }
154                 fn visit_bytes<__E>(
155                     self,
156                     __value: &[u8],
157                 ) -> _serde::__private::Result<Self::Value, __E>
158                 where
159                     __E: _serde::de::Error,
160                 {
161                     match __value {
162                         b"LifetimeSeq" => _serde::__private::Ok(__Field::__field0),
163                         b"NoLifetimeSeq" => _serde::__private::Ok(__Field::__field1),
164                         b"LifetimeMap" => _serde::__private::Ok(__Field::__field2),
165                         b"NoLifetimeMap" => _serde::__private::Ok(__Field::__field3),
166                         _ => {
167                             let __value = &_serde::__private::from_utf8_lossy(__value);
168                             _serde::__private::Err(_serde::de::Error::unknown_variant(
169                                 __value, VARIANTS,
170                             ))
171                         }
172                     }
173                 }
174             }
175             impl<'de> _serde::Deserialize<'de> for __Field {
176                 #[inline]
177                 fn deserialize<__D>(
178                     __deserializer: __D,
179                 ) -> _serde::__private::Result<Self, __D::Error>
180                 where
181                     __D: _serde::Deserializer<'de>,
182                 {
183                     _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor)
184                 }
185             }
186             struct __Visitor<'de, 'a> {
187                 marker: _serde::__private::PhantomData<Lifetimes<'a>>,
188                 lifetime: _serde::__private::PhantomData<&'de ()>,
189             }
190             impl<'de, 'a> _serde::de::Visitor<'de> for __Visitor<'de, 'a> {
191                 type Value = Lifetimes<'a>;
192                 fn expecting(
193                     &self,
194                     __formatter: &mut _serde::__private::Formatter,
195                 ) -> _serde::__private::fmt::Result {
196                     _serde::__private::Formatter::write_str(__formatter, "enum Lifetimes")
197                 }
198                 fn visit_enum<__A>(
199                     self,
200                     __data: __A,
201                 ) -> _serde::__private::Result<Self::Value, __A::Error>
202                 where
203                     __A: _serde::de::EnumAccess<'de>,
204                 {
205                     match match _serde::de::EnumAccess::variant(__data) {
206                         _serde::__private::Ok(__val) => __val,
207                         _serde::__private::Err(__err) => {
208                             return _serde::__private::Err(__err);
209                         }
210                     } {
211                         (__Field::__field0, __variant) => _serde::__private::Result::map(
212                             _serde::de::VariantAccess::newtype_variant::<&'a i32>(__variant),
213                             Lifetimes::LifetimeSeq,
214                         ),
215                         (__Field::__field1, __variant) => _serde::__private::Result::map(
216                             _serde::de::VariantAccess::newtype_variant::<i32>(__variant),
217                             Lifetimes::NoLifetimeSeq,
218                         ),
219                         (__Field::__field2, __variant) => {
220                             #[allow(non_camel_case_types)]
221                             enum __Field {
222                                 __field0,
223                                 __ignore,
224                             }
225                             struct __FieldVisitor;
226                             impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
227                                 type Value = __Field;
228                                 fn expecting(
229                                     &self,
230                                     __formatter: &mut _serde::__private::Formatter,
231                                 ) -> _serde::__private::fmt::Result
232                                 {
233                                     _serde::__private::Formatter::write_str(
234                                         __formatter,
235                                         "field identifier",
236                                     )
237                                 }
238                                 fn visit_u64<__E>(
239                                     self,
240                                     __value: u64,
241                                 ) -> _serde::__private::Result<Self::Value, __E>
242                                 where
243                                     __E: _serde::de::Error,
244                                 {
245                                     match __value {
246                                         0u64 => _serde::__private::Ok(__Field::__field0),
247                                         _ => _serde::__private::Ok(__Field::__ignore),
248                                     }
249                                 }
250                                 fn visit_str<__E>(
251                                     self,
252                                     __value: &str,
253                                 ) -> _serde::__private::Result<Self::Value, __E>
254                                 where
255                                     __E: _serde::de::Error,
256                                 {
257                                     match __value {
258                                         "a" => _serde::__private::Ok(__Field::__field0),
259                                         _ => _serde::__private::Ok(__Field::__ignore),
260                                     }
261                                 }
262                                 fn visit_bytes<__E>(
263                                     self,
264                                     __value: &[u8],
265                                 ) -> _serde::__private::Result<Self::Value, __E>
266                                 where
267                                     __E: _serde::de::Error,
268                                 {
269                                     match __value {
270                                         b"a" => _serde::__private::Ok(__Field::__field0),
271                                         _ => _serde::__private::Ok(__Field::__ignore),
272                                     }
273                                 }
274                             }
275                             impl<'de> _serde::Deserialize<'de> for __Field {
276                                 #[inline]
277                                 fn deserialize<__D>(
278                                     __deserializer: __D,
279                                 ) -> _serde::__private::Result<Self, __D::Error>
280                                 where
281                                     __D: _serde::Deserializer<'de>,
282                                 {
283                                     _serde::Deserializer::deserialize_identifier(
284                                         __deserializer,
285                                         __FieldVisitor,
286                                     )
287                                 }
288                             }
289                             struct __Visitor<'de, 'a> {
290                                 marker: _serde::__private::PhantomData<Lifetimes<'a>>,
291                                 lifetime: _serde::__private::PhantomData<&'de ()>,
292                             }
293                             impl<'de, 'a> _serde::de::Visitor<'de> for __Visitor<'de, 'a> {
294                                 type Value = Lifetimes<'a>;
295                                 fn expecting(
296                                     &self,
297                                     __formatter: &mut _serde::__private::Formatter,
298                                 ) -> _serde::__private::fmt::Result
299                                 {
300                                     _serde::__private::Formatter::write_str(
301                                         __formatter,
302                                         "struct variant Lifetimes::LifetimeMap",
303                                     )
304                                 }
305                                 #[inline]
306                                 fn visit_seq<__A>(
307                                     self,
308                                     mut __seq: __A,
309                                 ) -> _serde::__private::Result<Self::Value, __A::Error>
310                                 where
311                                     __A: _serde::de::SeqAccess<'de>,
312                                 {
313                                     let __field0 = match match _serde::de::SeqAccess::next_element::<
314                                         &'a i32,
315                                     >(
316                                         &mut __seq
317                                     ) {
318                                         _serde::__private::Ok(__val) => __val,
319                                         _serde::__private::Err(__err) => {
320                                             return _serde::__private::Err(__err);
321                                         }
322                                     } {
323                                         _serde::__private::Some(__value) => __value,
324                                         _serde::__private::None => {
325                                             return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (0usize , & "struct variant Lifetimes::LifetimeMap with 1 element")) ;
326                                         }
327                                     };
328                                     _serde::__private::Ok(Lifetimes::LifetimeMap { a: __field0 })
329                                 }
330                                 #[inline]
331                                 fn visit_map<__A>(
332                                     self,
333                                     mut __map: __A,
334                                 ) -> _serde::__private::Result<Self::Value, __A::Error>
335                                 where
336                                     __A: _serde::de::MapAccess<'de>,
337                                 {
338                                     let mut __field0: _serde::__private::Option<&'a i32> =
339                                         _serde::__private::None;
340                                     while let _serde::__private::Some(__key) =
341                                         match _serde::de::MapAccess::next_key::<__Field>(&mut __map)
342                                         {
343                                             _serde::__private::Ok(__val) => __val,
344                                             _serde::__private::Err(__err) => {
345                                                 return _serde::__private::Err(__err);
346                                             }
347                                         }
348                                     {
349                                         match __key {
350                                             __Field::__field0 => {
351                                                 if _serde::__private::Option::is_some(&__field0) {
352                                                     return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("a")) ;
353                                                 }
354                                                 __field0 = _serde::__private::Some(
355                                                     match _serde::de::MapAccess::next_value::<&'a i32>(
356                                                         &mut __map,
357                                                     ) {
358                                                         _serde::__private::Ok(__val) => __val,
359                                                         _serde::__private::Err(__err) => {
360                                                             return _serde::__private::Err(__err);
361                                                         }
362                                                     },
363                                                 );
364                                             }
365                                             _ => {
366                                                 let _ = match _serde::de::MapAccess::next_value::<
367                                                     _serde::de::IgnoredAny,
368                                                 >(
369                                                     &mut __map
370                                                 ) {
371                                                     _serde::__private::Ok(__val) => __val,
372                                                     _serde::__private::Err(__err) => {
373                                                         return _serde::__private::Err(__err);
374                                                     }
375                                                 };
376                                             }
377                                         }
378                                     }
379                                     let __field0 = match __field0 {
380                                         _serde::__private::Some(__field0) => __field0,
381                                         _serde::__private::None => {
382                                             match _serde::__private::de::missing_field("a") {
383                                                 _serde::__private::Ok(__val) => __val,
384                                                 _serde::__private::Err(__err) => {
385                                                     return _serde::__private::Err(__err);
386                                                 }
387                                             }
388                                         }
389                                     };
390                                     _serde::__private::Ok(Lifetimes::LifetimeMap { a: __field0 })
391                                 }
392                             }
393                             const FIELDS: &'static [&'static str] = &["a"];
394                             _serde::de::VariantAccess::struct_variant(
395                                 __variant,
396                                 FIELDS,
397                                 __Visitor {
398                                     marker: _serde::__private::PhantomData::<Lifetimes<'a>>,
399                                     lifetime: _serde::__private::PhantomData,
400                                 },
401                             )
402                         }
403                         (__Field::__field3, __variant) => {
404                             #[allow(non_camel_case_types)]
405                             enum __Field {
406                                 __field0,
407                                 __ignore,
408                             }
409                             struct __FieldVisitor;
410                             impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
411                                 type Value = __Field;
412                                 fn expecting(
413                                     &self,
414                                     __formatter: &mut _serde::__private::Formatter,
415                                 ) -> _serde::__private::fmt::Result
416                                 {
417                                     _serde::__private::Formatter::write_str(
418                                         __formatter,
419                                         "field identifier",
420                                     )
421                                 }
422                                 fn visit_u64<__E>(
423                                     self,
424                                     __value: u64,
425                                 ) -> _serde::__private::Result<Self::Value, __E>
426                                 where
427                                     __E: _serde::de::Error,
428                                 {
429                                     match __value {
430                                         0u64 => _serde::__private::Ok(__Field::__field0),
431                                         _ => _serde::__private::Ok(__Field::__ignore),
432                                     }
433                                 }
434                                 fn visit_str<__E>(
435                                     self,
436                                     __value: &str,
437                                 ) -> _serde::__private::Result<Self::Value, __E>
438                                 where
439                                     __E: _serde::de::Error,
440                                 {
441                                     match __value {
442                                         "a" => _serde::__private::Ok(__Field::__field0),
443                                         _ => _serde::__private::Ok(__Field::__ignore),
444                                     }
445                                 }
446                                 fn visit_bytes<__E>(
447                                     self,
448                                     __value: &[u8],
449                                 ) -> _serde::__private::Result<Self::Value, __E>
450                                 where
451                                     __E: _serde::de::Error,
452                                 {
453                                     match __value {
454                                         b"a" => _serde::__private::Ok(__Field::__field0),
455                                         _ => _serde::__private::Ok(__Field::__ignore),
456                                     }
457                                 }
458                             }
459                             impl<'de> _serde::Deserialize<'de> for __Field {
460                                 #[inline]
461                                 fn deserialize<__D>(
462                                     __deserializer: __D,
463                                 ) -> _serde::__private::Result<Self, __D::Error>
464                                 where
465                                     __D: _serde::Deserializer<'de>,
466                                 {
467                                     _serde::Deserializer::deserialize_identifier(
468                                         __deserializer,
469                                         __FieldVisitor,
470                                     )
471                                 }
472                             }
473                             struct __Visitor<'de, 'a> {
474                                 marker: _serde::__private::PhantomData<Lifetimes<'a>>,
475                                 lifetime: _serde::__private::PhantomData<&'de ()>,
476                             }
477                             impl<'de, 'a> _serde::de::Visitor<'de> for __Visitor<'de, 'a> {
478                                 type Value = Lifetimes<'a>;
479                                 fn expecting(
480                                     &self,
481                                     __formatter: &mut _serde::__private::Formatter,
482                                 ) -> _serde::__private::fmt::Result
483                                 {
484                                     _serde::__private::Formatter::write_str(
485                                         __formatter,
486                                         "struct variant Lifetimes::NoLifetimeMap",
487                                     )
488                                 }
489                                 #[inline]
490                                 fn visit_seq<__A>(
491                                     self,
492                                     mut __seq: __A,
493                                 ) -> _serde::__private::Result<Self::Value, __A::Error>
494                                 where
495                                     __A: _serde::de::SeqAccess<'de>,
496                                 {
497                                     let __field0 = match match _serde::de::SeqAccess::next_element::<
498                                         i32,
499                                     >(
500                                         &mut __seq
501                                     ) {
502                                         _serde::__private::Ok(__val) => __val,
503                                         _serde::__private::Err(__err) => {
504                                             return _serde::__private::Err(__err);
505                                         }
506                                     } {
507                                         _serde::__private::Some(__value) => __value,
508                                         _serde::__private::None => {
509                                             return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (0usize , & "struct variant Lifetimes::NoLifetimeMap with 1 element")) ;
510                                         }
511                                     };
512                                     _serde::__private::Ok(Lifetimes::NoLifetimeMap { a: __field0 })
513                                 }
514                                 #[inline]
515                                 fn visit_map<__A>(
516                                     self,
517                                     mut __map: __A,
518                                 ) -> _serde::__private::Result<Self::Value, __A::Error>
519                                 where
520                                     __A: _serde::de::MapAccess<'de>,
521                                 {
522                                     let mut __field0: _serde::__private::Option<i32> =
523                                         _serde::__private::None;
524                                     while let _serde::__private::Some(__key) =
525                                         match _serde::de::MapAccess::next_key::<__Field>(&mut __map)
526                                         {
527                                             _serde::__private::Ok(__val) => __val,
528                                             _serde::__private::Err(__err) => {
529                                                 return _serde::__private::Err(__err);
530                                             }
531                                         }
532                                     {
533                                         match __key {
534                                             __Field::__field0 => {
535                                                 if _serde::__private::Option::is_some(&__field0) {
536                                                     return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("a")) ;
537                                                 }
538                                                 __field0 = _serde::__private::Some(
539                                                     match _serde::de::MapAccess::next_value::<i32>(
540                                                         &mut __map,
541                                                     ) {
542                                                         _serde::__private::Ok(__val) => __val,
543                                                         _serde::__private::Err(__err) => {
544                                                             return _serde::__private::Err(__err);
545                                                         }
546                                                     },
547                                                 );
548                                             }
549                                             _ => {
550                                                 let _ = match _serde::de::MapAccess::next_value::<
551                                                     _serde::de::IgnoredAny,
552                                                 >(
553                                                     &mut __map
554                                                 ) {
555                                                     _serde::__private::Ok(__val) => __val,
556                                                     _serde::__private::Err(__err) => {
557                                                         return _serde::__private::Err(__err);
558                                                     }
559                                                 };
560                                             }
561                                         }
562                                     }
563                                     let __field0 = match __field0 {
564                                         _serde::__private::Some(__field0) => __field0,
565                                         _serde::__private::None => {
566                                             match _serde::__private::de::missing_field("a") {
567                                                 _serde::__private::Ok(__val) => __val,
568                                                 _serde::__private::Err(__err) => {
569                                                     return _serde::__private::Err(__err);
570                                                 }
571                                             }
572                                         }
573                                     };
574                                     _serde::__private::Ok(Lifetimes::NoLifetimeMap { a: __field0 })
575                                 }
576                             }
577                             const FIELDS: &'static [&'static str] = &["a"];
578                             _serde::de::VariantAccess::struct_variant(
579                                 __variant,
580                                 FIELDS,
581                                 __Visitor {
582                                     marker: _serde::__private::PhantomData::<Lifetimes<'a>>,
583                                     lifetime: _serde::__private::PhantomData,
584                                 },
585                             )
586                         }
587                     }
588                 }
589             }
590             const VARIANTS: &'static [&'static str] = &[
591                 "LifetimeSeq",
592                 "NoLifetimeSeq",
593                 "LifetimeMap",
594                 "NoLifetimeMap",
595             ];
596             _serde::Deserializer::deserialize_enum(
597                 __deserializer,
598                 "Lifetimes",
599                 VARIANTS,
600                 __Visitor {
601                     marker: _serde::__private::PhantomData::<Lifetimes<'a>>,
602                     lifetime: _serde::__private::PhantomData,
603                 },
604             )
605         }
606     }
607 };
608