serde/test_suite/tests/expand/named_map.expanded.rs
2022-06-20 03:40:49 -07:00

687 lines
30 KiB
Rust
Generated

use serde::{Deserialize, Serialize};
struct SerNamedMap<'a, 'b, A: 'a, B: 'b, C> {
a: &'a A,
b: &'b mut B,
c: C,
}
#[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _: () = {
#[allow(unused_extern_crates, clippy::useless_attribute)]
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>
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);
}
};
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);
}
};
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);
}
};
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);
}
};
_serde::ser::SerializeStruct::end(__serde_state)
}
}
};
struct DeNamedMap<A, B, C> {
a: A,
b: B,
c: C,
}
#[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _: () = {
#[allow(unused_extern_crates, clippy::useless_attribute)]
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>
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",
)
}
fn visit_u64<__E>(
self,
__value: u64,
) -> _serde::__private::Result<Self::Value, __E>
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),
}
}
fn visit_str<__E>(
self,
__value: &str,
) -> _serde::__private::Result<Self::Value, __E>
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),
}
}
fn visit_bytes<__E>(
self,
__value: &[u8],
) -> _serde::__private::Result<Self::Value, __E>
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),
}
}
}
impl<'de> _serde::Deserialize<'de> for __Field {
#[inline]
fn deserialize<__D>(
__deserializer: __D,
) -> _serde::__private::Result<Self, __D::Error>
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 ()>,
}
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",
)
}
#[inline]
fn visit_seq<__A>(
self,
mut __seq: __A,
) -> _serde::__private::Result<Self::Value, __A::Error>
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);
}
} {
_serde::__private::Some(__value) => __value,
_serde::__private::None => {
return _serde::__private::Err(
_serde::de::Error::invalid_length(
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);
}
} {
_serde::__private::Some(__value) => __value,
_serde::__private::None => {
return _serde::__private::Err(
_serde::de::Error::invalid_length(
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);
}
} {
_serde::__private::Some(__value) => __value,
_serde::__private::None => {
return _serde::__private::Err(
_serde::de::Error::invalid_length(
2usize,
&"struct DeNamedMap with 3 elements",
),
);
}
};
_serde::__private::Ok(DeNamedMap {
a: __field0,
b: __field1,
c: __field2,
})
}
#[inline]
fn visit_map<__A>(
self,
mut __map: __A,
) -> _serde::__private::Result<Self::Value, __A::Error>
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)
= match _serde::de::MapAccess::next_key::<__Field>(&mut __map) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
} {
match __key {
__Field::__field0 => {
if _serde::__private::Option::is_some(&__field0) {
return _serde::__private::Err(
<__A::Error as _serde::de::Error>::duplicate_field("a"),
);
}
__field0 = _serde::__private::Some(
match _serde::de::MapAccess::next_value::<A>(&mut __map) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
},
);
}
__Field::__field1 => {
if _serde::__private::Option::is_some(&__field1) {
return _serde::__private::Err(
<__A::Error as _serde::de::Error>::duplicate_field("b"),
);
}
__field1 = _serde::__private::Some(
match _serde::de::MapAccess::next_value::<B>(&mut __map) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
},
);
}
__Field::__field2 => {
if _serde::__private::Option::is_some(&__field2) {
return _serde::__private::Err(
<__A::Error as _serde::de::Error>::duplicate_field("c"),
);
}
__field2 = _serde::__private::Some(
match _serde::de::MapAccess::next_value::<C>(&mut __map) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
},
);
}
_ => {
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);
}
};
}
}
}
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);
}
}
}
};
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);
}
}
}
};
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);
}
}
}
};
_serde::__private::Ok(DeNamedMap {
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,
},
)
}
fn deserialize_in_place<__D>(
__deserializer: __D,
__place: &mut Self,
) -> _serde::__private::Result<(), __D::Error>
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",
)
}
fn visit_u64<__E>(
self,
__value: u64,
) -> _serde::__private::Result<Self::Value, __E>
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),
}
}
fn visit_str<__E>(
self,
__value: &str,
) -> _serde::__private::Result<Self::Value, __E>
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),
}
}
fn visit_bytes<__E>(
self,
__value: &[u8],
) -> _serde::__private::Result<Self::Value, __E>
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),
}
}
}
impl<'de> _serde::Deserialize<'de> for __Field {
#[inline]
fn deserialize<__D>(
__deserializer: __D,
) -> _serde::__private::Result<Self, __D::Error>
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 ()>,
}
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",
)
}
#[inline]
fn visit_seq<__A>(
self,
mut __seq: __A,
) -> _serde::__private::Result<Self::Value, __A::Error>
where
__A: _serde::de::SeqAccess<'de>,
{
if let _serde::__private::None
= match _serde::de::SeqAccess::next_element_seed(
&mut __seq,
_serde::__private::de::InPlaceSeed(&mut self.place.a),
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
} {
return _serde::__private::Err(
_serde::de::Error::invalid_length(
0usize,
&"struct DeNamedMap with 3 elements",
),
);
}
if let _serde::__private::None
= match _serde::de::SeqAccess::next_element_seed(
&mut __seq,
_serde::__private::de::InPlaceSeed(&mut self.place.b),
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
} {
return _serde::__private::Err(
_serde::de::Error::invalid_length(
1usize,
&"struct DeNamedMap with 3 elements",
),
);
}
if let _serde::__private::None
= match _serde::de::SeqAccess::next_element_seed(
&mut __seq,
_serde::__private::de::InPlaceSeed(&mut self.place.c),
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
} {
return _serde::__private::Err(
_serde::de::Error::invalid_length(
2usize,
&"struct DeNamedMap with 3 elements",
),
);
}
_serde::__private::Ok(())
}
#[inline]
fn visit_map<__A>(
self,
mut __map: __A,
) -> _serde::__private::Result<Self::Value, __A::Error>
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)
= match _serde::de::MapAccess::next_key::<__Field>(&mut __map) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
} {
match __key {
__Field::__field0 => {
if __field0 {
return _serde::__private::Err(
<__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),
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
};
__field0 = true;
}
__Field::__field1 => {
if __field1 {
return _serde::__private::Err(
<__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),
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
};
__field1 = true;
}
__Field::__field2 => {
if __field2 {
return _serde::__private::Err(
<__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),
) {
_serde::__private::Ok(__val) => __val,
_serde::__private::Err(__err) => {
return _serde::__private::Err(__err);
}
};
__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);
}
};
}
}
}
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);
}
};
}
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);
}
};
}
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);
}
};
}
_serde::__private::Ok(())
}
}
const FIELDS: &'static [&'static str] = &["a", "b", "c"];
_serde::Deserializer::deserialize_struct(
__deserializer,
"DeNamedMap",
FIELDS,
__Visitor {
place: __place,
lifetime: _serde::__private::PhantomData,
},
)
}
}
};