serde/test_suite/tests/expand/named_map.expanded.rs

629 lines
28 KiB
Rust
Raw Normal View History

2019-10-31 13:32:34 -05:00
use serde::{Deserialize, Serialize};
struct SerNamedMap<'a, 'b, A: 'a, B: 'b, C> {
a: &'a A,
b: &'b mut B,
c: C,
}
#[doc(hidden)]
2019-10-31 13:32:34 -05:00
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
2020-06-07 00:41:07 -05:00
const _: () = {
#[allow(rust_2018_idioms, clippy::useless_attribute)]
2019-10-31 13:32:34 -05:00
extern crate serde as _serde;
#[automatically_derived]
impl<'a, 'b, A: 'a, B: 'b, C> _serde::Serialize for SerNamedMap<'a, 'b, A, B, C>
where
A: _serde::Serialize,
B: _serde::Serialize,
C: _serde::Serialize,
{
fn serialize<__S>(
&self,
__serializer: __S,
) -> _serde::__private::Result<__S::Ok, __S::Error>
2019-10-31 13:32:34 -05:00
where
__S: _serde::Serializer,
{
let mut __serde_state = match _serde::Serializer::serialize_struct(
__serializer,
"SerNamedMap",
false as usize + 1 + 1 + 1,
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
match _serde::ser::SerializeStruct::serialize_field(&mut __serde_state, "a", &self.a) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
match _serde::ser::SerializeStruct::serialize_field(&mut __serde_state, "b", &self.b) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
match _serde::ser::SerializeStruct::serialize_field(&mut __serde_state, "c", &self.c) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
_serde::ser::SerializeStruct::end(__serde_state)
}
}
};
struct DeNamedMap<A, B, C> {
a: A,
b: B,
c: C,
}
#[doc(hidden)]
2019-10-31 13:32:34 -05:00
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
2020-06-07 00:41:07 -05:00
const _: () = {
#[allow(rust_2018_idioms, clippy::useless_attribute)]
2019-10-31 13:32:34 -05:00
extern crate serde as _serde;
#[automatically_derived]
impl<'de, A, B, C> _serde::Deserialize<'de> for DeNamedMap<A, B, C>
where
A: _serde::Deserialize<'de>,
B: _serde::Deserialize<'de>,
C: _serde::Deserialize<'de>,
{
fn deserialize<__D>(__deserializer: __D) -> _serde::__private::Result<Self, __D::Error>
2019-10-31 13:32:34 -05:00
where
__D: _serde::Deserializer<'de>,
{
#[allow(non_camel_case_types)]
enum __Field {
__field0,
__field1,
__field2,
__ignore,
}
struct __FieldVisitor;
impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
type Value = __Field;
fn expecting(
&self,
__formatter: &mut _serde::__private::Formatter,
) -> _serde::__private::fmt::Result {
_serde::__private::Formatter::write_str(__formatter, "field identifier")
2019-10-31 13:32:34 -05:00
}
fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result<Self::Value, __E>
2019-10-31 13:32:34 -05:00
where
__E: _serde::de::Error,
{
match __value {
0u64 => _serde::__private::Ok(__Field::__field0),
1u64 => _serde::__private::Ok(__Field::__field1),
2u64 => _serde::__private::Ok(__Field::__field2),
_ => _serde::__private::Ok(__Field::__ignore),
2019-10-31 13:32:34 -05:00
}
}
fn visit_str<__E>(
self,
__value: &str,
) -> _serde::__private::Result<Self::Value, __E>
2019-10-31 13:32:34 -05:00
where
__E: _serde::de::Error,
{
match __value {
"a" => _serde::__private::Ok(__Field::__field0),
"b" => _serde::__private::Ok(__Field::__field1),
"c" => _serde::__private::Ok(__Field::__field2),
_ => _serde::__private::Ok(__Field::__ignore),
2019-10-31 13:32:34 -05:00
}
}
fn visit_bytes<__E>(
self,
__value: &[u8],
) -> _serde::__private::Result<Self::Value, __E>
2019-10-31 13:32:34 -05:00
where
__E: _serde::de::Error,
{
match __value {
b"a" => _serde::__private::Ok(__Field::__field0),
b"b" => _serde::__private::Ok(__Field::__field1),
b"c" => _serde::__private::Ok(__Field::__field2),
_ => _serde::__private::Ok(__Field::__ignore),
2019-10-31 13:32:34 -05:00
}
}
}
impl<'de> _serde::Deserialize<'de> for __Field {
#[inline]
fn deserialize<__D>(
__deserializer: __D,
) -> _serde::__private::Result<Self, __D::Error>
2019-10-31 13:32:34 -05:00
where
__D: _serde::Deserializer<'de>,
{
_serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor)
}
}
struct __Visitor<'de, A, B, C>
where
A: _serde::Deserialize<'de>,
B: _serde::Deserialize<'de>,
C: _serde::Deserialize<'de>,
{
marker: _serde::__private::PhantomData<DeNamedMap<A, B, C>>,
lifetime: _serde::__private::PhantomData<&'de ()>,
2019-10-31 13:32:34 -05:00
}
impl<'de, A, B, C> _serde::de::Visitor<'de> for __Visitor<'de, A, B, C>
where
A: _serde::Deserialize<'de>,
B: _serde::Deserialize<'de>,
C: _serde::Deserialize<'de>,
{
type Value = DeNamedMap<A, B, C>;
fn expecting(
&self,
__formatter: &mut _serde::__private::Formatter,
) -> _serde::__private::fmt::Result {
_serde::__private::Formatter::write_str(__formatter, "struct DeNamedMap")
2019-10-31 13:32:34 -05:00
}
#[inline]
fn visit_seq<__A>(
self,
mut __seq: __A,
) -> _serde::__private::Result<Self::Value, __A::Error>
2019-10-31 13:32:34 -05:00
where
__A: _serde::de::SeqAccess<'de>,
{
let __field0 = match match _serde::de::SeqAccess::next_element::<A>(&mut __seq)
{
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
} {
_serde::__private::Some(__value) => __value,
_serde::__private::None => {
return _serde::__private::Err(_serde::de::Error::invalid_length(
2019-10-31 13:32:34 -05:00
0usize,
&"struct DeNamedMap with 3 elements",
));
}
};
let __field1 = match match _serde::de::SeqAccess::next_element::<B>(&mut __seq)
{
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
} {
_serde::__private::Some(__value) => __value,
_serde::__private::None => {
return _serde::__private::Err(_serde::de::Error::invalid_length(
2019-10-31 13:32:34 -05:00
1usize,
&"struct DeNamedMap with 3 elements",
));
}
};
let __field2 = match match _serde::de::SeqAccess::next_element::<C>(&mut __seq)
{
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
} {
_serde::__private::Some(__value) => __value,
_serde::__private::None => {
return _serde::__private::Err(_serde::de::Error::invalid_length(
2019-10-31 13:32:34 -05:00
2usize,
&"struct DeNamedMap with 3 elements",
));
}
};
_serde::__private::Ok(DeNamedMap {
2019-10-31 13:32:34 -05:00
a: __field0,
b: __field1,
c: __field2,
})
}
#[inline]
fn visit_map<__A>(
self,
mut __map: __A,
) -> _serde::__private::Result<Self::Value, __A::Error>
2019-10-31 13:32:34 -05:00
where
__A: _serde::de::MapAccess<'de>,
{
let mut __field0: _serde::__private::Option<A> = _serde::__private::None;
let mut __field1: _serde::__private::Option<B> = _serde::__private::None;
let mut __field2: _serde::__private::Option<C> = _serde::__private::None;
while let _serde::__private::Some(__key) =
2019-10-31 13:32:34 -05:00
match _serde::de::MapAccess::next_key::<__Field>(&mut __map) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
}
{
match __key {
__Field::__field0 => {
if _serde::__private::Option::is_some(&__field0) {
return _serde::__private::Err(
2019-10-31 13:32:34 -05:00
<__A::Error as _serde::de::Error>::duplicate_field("a"),
);
}
__field0 = _serde::__private::Some(
2019-10-31 13:32:34 -05:00
match _serde::de::MapAccess::next_value::<A>(&mut __map) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
},
);
}
__Field::__field1 => {
if _serde::__private::Option::is_some(&__field1) {
return _serde::__private::Err(
2019-10-31 13:32:34 -05:00
<__A::Error as _serde::de::Error>::duplicate_field("b"),
);
}
__field1 = _serde::__private::Some(
2019-10-31 13:32:34 -05:00
match _serde::de::MapAccess::next_value::<B>(&mut __map) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
},
);
}
__Field::__field2 => {
if _serde::__private::Option::is_some(&__field2) {
return _serde::__private::Err(
2019-10-31 13:32:34 -05:00
<__A::Error as _serde::de::Error>::duplicate_field("c"),
);
}
__field2 = _serde::__private::Some(
2019-10-31 13:32:34 -05:00
match _serde::de::MapAccess::next_value::<C>(&mut __map) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
},
);
}
_ => {
let _ = match _serde::de::MapAccess::next_value::<
_serde::de::IgnoredAny,
>(&mut __map)
{
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
}
}
}
let __field0 = match __field0 {
_serde::__private::Some(__field0) => __field0,
_serde::__private::None => {
match _serde::__private::de::missing_field("a") {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
2019-10-31 13:32:34 -05:00
}
}
2019-10-31 13:32:34 -05:00
};
let __field1 = match __field1 {
_serde::__private::Some(__field1) => __field1,
_serde::__private::None => {
match _serde::__private::de::missing_field("b") {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
2019-10-31 13:32:34 -05:00
}
}
2019-10-31 13:32:34 -05:00
};
let __field2 = match __field2 {
_serde::__private::Some(__field2) => __field2,
_serde::__private::None => {
match _serde::__private::de::missing_field("c") {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
2019-10-31 13:32:34 -05:00
}
}
2019-10-31 13:32:34 -05:00
};
_serde::__private::Ok(DeNamedMap {
2019-10-31 13:32:34 -05:00
a: __field0,
b: __field1,
c: __field2,
})
}
}
const FIELDS: &'static [&'static str] = &["a", "b", "c"];
_serde::Deserializer::deserialize_struct(
__deserializer,
"DeNamedMap",
FIELDS,
__Visitor {
marker: _serde::__private::PhantomData::<DeNamedMap<A, B, C>>,
lifetime: _serde::__private::PhantomData,
2019-10-31 13:32:34 -05:00
},
)
}
fn deserialize_in_place<__D>(
__deserializer: __D,
__place: &mut Self,
) -> _serde::__private::Result<(), __D::Error>
2019-10-31 13:32:34 -05:00
where
__D: _serde::Deserializer<'de>,
{
#[allow(non_camel_case_types)]
enum __Field {
__field0,
__field1,
__field2,
__ignore,
}
struct __FieldVisitor;
impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
type Value = __Field;
fn expecting(
&self,
__formatter: &mut _serde::__private::Formatter,
) -> _serde::__private::fmt::Result {
_serde::__private::Formatter::write_str(__formatter, "field identifier")
2019-10-31 13:32:34 -05:00
}
fn visit_u64<__E>(self, __value: u64) -> _serde::__private::Result<Self::Value, __E>
2019-10-31 13:32:34 -05:00
where
__E: _serde::de::Error,
{
match __value {
0u64 => _serde::__private::Ok(__Field::__field0),
1u64 => _serde::__private::Ok(__Field::__field1),
2u64 => _serde::__private::Ok(__Field::__field2),
_ => _serde::__private::Ok(__Field::__ignore),
2019-10-31 13:32:34 -05:00
}
}
fn visit_str<__E>(
self,
__value: &str,
) -> _serde::__private::Result<Self::Value, __E>
2019-10-31 13:32:34 -05:00
where
__E: _serde::de::Error,
{
match __value {
"a" => _serde::__private::Ok(__Field::__field0),
"b" => _serde::__private::Ok(__Field::__field1),
"c" => _serde::__private::Ok(__Field::__field2),
_ => _serde::__private::Ok(__Field::__ignore),
2019-10-31 13:32:34 -05:00
}
}
fn visit_bytes<__E>(
self,
__value: &[u8],
) -> _serde::__private::Result<Self::Value, __E>
2019-10-31 13:32:34 -05:00
where
__E: _serde::de::Error,
{
match __value {
b"a" => _serde::__private::Ok(__Field::__field0),
b"b" => _serde::__private::Ok(__Field::__field1),
b"c" => _serde::__private::Ok(__Field::__field2),
_ => _serde::__private::Ok(__Field::__ignore),
2019-10-31 13:32:34 -05:00
}
}
}
impl<'de> _serde::Deserialize<'de> for __Field {
#[inline]
fn deserialize<__D>(
__deserializer: __D,
) -> _serde::__private::Result<Self, __D::Error>
2019-10-31 13:32:34 -05:00
where
__D: _serde::Deserializer<'de>,
{
_serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor)
}
}
struct __Visitor<'de, 'place, A: 'place, B: 'place, C: 'place>
where
A: _serde::Deserialize<'de>,
B: _serde::Deserialize<'de>,
C: _serde::Deserialize<'de>,
{
place: &'place mut DeNamedMap<A, B, C>,
lifetime: _serde::__private::PhantomData<&'de ()>,
2019-10-31 13:32:34 -05:00
}
impl<'de, 'place, A: 'place, B: 'place, C: 'place> _serde::de::Visitor<'de>
for __Visitor<'de, 'place, A, B, C>
where
A: _serde::Deserialize<'de>,
B: _serde::Deserialize<'de>,
C: _serde::Deserialize<'de>,
{
type Value = ();
fn expecting(
&self,
__formatter: &mut _serde::__private::Formatter,
) -> _serde::__private::fmt::Result {
_serde::__private::Formatter::write_str(__formatter, "struct DeNamedMap")
2019-10-31 13:32:34 -05:00
}
#[inline]
fn visit_seq<__A>(
self,
mut __seq: __A,
) -> _serde::__private::Result<Self::Value, __A::Error>
2019-10-31 13:32:34 -05:00
where
__A: _serde::de::SeqAccess<'de>,
{
if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed(
2019-10-31 13:32:34 -05:00
&mut __seq,
_serde::__private::de::InPlaceSeed(&mut self.place.a),
2019-10-31 13:32:34 -05:00
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
} {
return _serde::__private::Err(_serde::de::Error::invalid_length(
2019-10-31 13:32:34 -05:00
0usize,
&"struct DeNamedMap with 3 elements",
));
}
if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed(
2019-10-31 13:32:34 -05:00
&mut __seq,
_serde::__private::de::InPlaceSeed(&mut self.place.b),
2019-10-31 13:32:34 -05:00
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
} {
return _serde::__private::Err(_serde::de::Error::invalid_length(
2019-10-31 13:32:34 -05:00
1usize,
&"struct DeNamedMap with 3 elements",
));
}
if let _serde::__private::None = match _serde::de::SeqAccess::next_element_seed(
2019-10-31 13:32:34 -05:00
&mut __seq,
_serde::__private::de::InPlaceSeed(&mut self.place.c),
2019-10-31 13:32:34 -05:00
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
} {
return _serde::__private::Err(_serde::de::Error::invalid_length(
2019-10-31 13:32:34 -05:00
2usize,
&"struct DeNamedMap with 3 elements",
));
}
_serde::__private::Ok(())
2019-10-31 13:32:34 -05:00
}
#[inline]
fn visit_map<__A>(
self,
mut __map: __A,
) -> _serde::__private::Result<Self::Value, __A::Error>
2019-10-31 13:32:34 -05:00
where
__A: _serde::de::MapAccess<'de>,
{
let mut __field0: bool = false;
let mut __field1: bool = false;
let mut __field2: bool = false;
while let _serde::__private::Some(__key) =
2019-10-31 13:32:34 -05:00
match _serde::de::MapAccess::next_key::<__Field>(&mut __map) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
}
{
match __key {
__Field::__field0 => {
if __field0 {
return _serde::__private::Err(
2019-10-31 13:32:34 -05:00
<__A::Error as _serde::de::Error>::duplicate_field("a"),
);
}
match _serde::de::MapAccess::next_value_seed(
&mut __map,
_serde::__private::de::InPlaceSeed(&mut self.place.a),
2019-10-31 13:32:34 -05:00
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
__field0 = true;
}
__Field::__field1 => {
if __field1 {
return _serde::__private::Err(
2019-10-31 13:32:34 -05:00
<__A::Error as _serde::de::Error>::duplicate_field("b"),
);
}
match _serde::de::MapAccess::next_value_seed(
&mut __map,
_serde::__private::de::InPlaceSeed(&mut self.place.b),
2019-10-31 13:32:34 -05:00
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
__field1 = true;
}
__Field::__field2 => {
if __field2 {
return _serde::__private::Err(
2019-10-31 13:32:34 -05:00
<__A::Error as _serde::de::Error>::duplicate_field("c"),
);
}
match _serde::de::MapAccess::next_value_seed(
&mut __map,
_serde::__private::de::InPlaceSeed(&mut self.place.c),
2019-10-31 13:32:34 -05:00
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
__field2 = true;
}
_ => {
let _ = match _serde::de::MapAccess::next_value::<
_serde::de::IgnoredAny,
>(&mut __map)
{
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
}
}
}
if !__field0 {
self.place.a = match _serde::__private::de::missing_field("a") {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
};
if !__field1 {
self.place.b = match _serde::__private::de::missing_field("b") {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
};
if !__field2 {
self.place.c = match _serde::__private::de::missing_field("c") {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
2019-10-31 13:32:34 -05:00
}
};
};
_serde::__private::Ok(())
2019-10-31 13:32:34 -05:00
}
}
const FIELDS: &'static [&'static str] = &["a", "b", "c"];
_serde::Deserializer::deserialize_struct(
__deserializer,
"DeNamedMap",
FIELDS,
__Visitor {
place: __place,
lifetime: _serde::__private::PhantomData,
2019-10-31 13:32:34 -05:00
},
)
}
}
};