2019-10-31 13:32:34 -05:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
pub enum GenericEnum<T, U> {
|
|
|
|
Unit,
|
|
|
|
NewType(T),
|
|
|
|
Seq(T, U),
|
|
|
|
Map { x: T, y: U },
|
|
|
|
}
|
2020-05-05 19:22:53 -05:00
|
|
|
#[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 _: () = {
|
2020-05-05 19:22:53 -05:00
|
|
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
2019-10-31 13:32:34 -05:00
|
|
|
extern crate serde as _serde;
|
|
|
|
#[automatically_derived]
|
|
|
|
impl<T, U> _serde::Serialize for GenericEnum<T, U>
|
|
|
|
where
|
|
|
|
T: _serde::Serialize,
|
|
|
|
U: _serde::Serialize,
|
|
|
|
{
|
2021-01-08 21:35:52 -06:00
|
|
|
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,
|
|
|
|
{
|
|
|
|
match *self {
|
|
|
|
GenericEnum::Unit => _serde::Serializer::serialize_unit_variant(
|
|
|
|
__serializer,
|
|
|
|
"GenericEnum",
|
|
|
|
0u32,
|
|
|
|
"Unit",
|
|
|
|
),
|
|
|
|
GenericEnum::NewType(ref __field0) => {
|
|
|
|
_serde::Serializer::serialize_newtype_variant(
|
|
|
|
__serializer,
|
|
|
|
"GenericEnum",
|
|
|
|
1u32,
|
|
|
|
"NewType",
|
|
|
|
__field0,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
GenericEnum::Seq(ref __field0, ref __field1) => {
|
|
|
|
let mut __serde_state = match _serde::Serializer::serialize_tuple_variant(
|
|
|
|
__serializer,
|
|
|
|
"GenericEnum",
|
|
|
|
2u32,
|
|
|
|
"Seq",
|
|
|
|
0 + 1 + 1,
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_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::SerializeTupleVariant::serialize_field(
|
|
|
|
&mut __serde_state,
|
|
|
|
__field0,
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_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::SerializeTupleVariant::serialize_field(
|
|
|
|
&mut __serde_state,
|
|
|
|
__field1,
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(__val) => __val,
|
|
|
|
_serde::__private::Err(__err) => {
|
|
|
|
return _serde::__private::Err(__err);
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
_serde::ser::SerializeTupleVariant::end(__serde_state)
|
|
|
|
}
|
|
|
|
GenericEnum::Map { ref x, ref y } => {
|
|
|
|
let mut __serde_state = match _serde::Serializer::serialize_struct_variant(
|
|
|
|
__serializer,
|
|
|
|
"GenericEnum",
|
|
|
|
3u32,
|
|
|
|
"Map",
|
|
|
|
0 + 1 + 1,
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_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::SerializeStructVariant::serialize_field(
|
|
|
|
&mut __serde_state,
|
|
|
|
"x",
|
|
|
|
x,
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_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::SerializeStructVariant::serialize_field(
|
|
|
|
&mut __serde_state,
|
|
|
|
"y",
|
|
|
|
y,
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(__val) => __val,
|
|
|
|
_serde::__private::Err(__err) => {
|
|
|
|
return _serde::__private::Err(__err);
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
_serde::ser::SerializeStructVariant::end(__serde_state)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2020-05-05 19:22:53 -05:00
|
|
|
#[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 _: () = {
|
2020-05-05 19:22:53 -05:00
|
|
|
#[allow(rust_2018_idioms, clippy::useless_attribute)]
|
2019-10-31 13:32:34 -05:00
|
|
|
extern crate serde as _serde;
|
|
|
|
#[automatically_derived]
|
|
|
|
impl<'de, T, U> _serde::Deserialize<'de> for GenericEnum<T, U>
|
|
|
|
where
|
|
|
|
T: _serde::Deserialize<'de>,
|
|
|
|
U: _serde::Deserialize<'de>,
|
|
|
|
{
|
2021-01-08 21:35:52 -06:00
|
|
|
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,
|
|
|
|
__field3,
|
|
|
|
}
|
|
|
|
struct __FieldVisitor;
|
|
|
|
impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
|
|
|
|
type Value = __Field;
|
|
|
|
fn expecting(
|
|
|
|
&self,
|
2021-01-08 21:35:52 -06:00
|
|
|
__formatter: &mut _serde::__private::Formatter,
|
|
|
|
) -> _serde::__private::fmt::Result {
|
|
|
|
_serde::__private::Formatter::write_str(__formatter, "variant identifier")
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
2021-01-08 21:35:52 -06: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 {
|
2021-01-08 21:35:52 -06:00
|
|
|
0u64 => _serde::__private::Ok(__Field::__field0),
|
|
|
|
1u64 => _serde::__private::Ok(__Field::__field1),
|
|
|
|
2u64 => _serde::__private::Ok(__Field::__field2),
|
|
|
|
3u64 => _serde::__private::Ok(__Field::__field3),
|
|
|
|
_ => _serde::__private::Err(_serde::de::Error::invalid_value(
|
2019-10-31 13:32:34 -05:00
|
|
|
_serde::de::Unexpected::Unsigned(__value),
|
|
|
|
&"variant index 0 <= i < 4",
|
|
|
|
)),
|
|
|
|
}
|
|
|
|
}
|
2021-01-08 21:35:52 -06: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 {
|
2021-01-08 21:35:52 -06:00
|
|
|
"Unit" => _serde::__private::Ok(__Field::__field0),
|
|
|
|
"NewType" => _serde::__private::Ok(__Field::__field1),
|
|
|
|
"Seq" => _serde::__private::Ok(__Field::__field2),
|
|
|
|
"Map" => _serde::__private::Ok(__Field::__field3),
|
|
|
|
_ => _serde::__private::Err(_serde::de::Error::unknown_variant(
|
2019-10-31 13:32:34 -05:00
|
|
|
__value, VARIANTS,
|
|
|
|
)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn visit_bytes<__E>(
|
|
|
|
self,
|
|
|
|
__value: &[u8],
|
2021-01-08 21:35:52 -06:00
|
|
|
) -> _serde::__private::Result<Self::Value, __E>
|
2019-10-31 13:32:34 -05:00
|
|
|
where
|
|
|
|
__E: _serde::de::Error,
|
|
|
|
{
|
|
|
|
match __value {
|
2021-01-08 21:35:52 -06:00
|
|
|
b"Unit" => _serde::__private::Ok(__Field::__field0),
|
|
|
|
b"NewType" => _serde::__private::Ok(__Field::__field1),
|
|
|
|
b"Seq" => _serde::__private::Ok(__Field::__field2),
|
|
|
|
b"Map" => _serde::__private::Ok(__Field::__field3),
|
2019-10-31 13:32:34 -05:00
|
|
|
_ => {
|
2021-01-08 21:35:52 -06:00
|
|
|
let __value = &_serde::__private::from_utf8_lossy(__value);
|
|
|
|
_serde::__private::Err(_serde::de::Error::unknown_variant(
|
2019-10-31 13:32:34 -05:00
|
|
|
__value, VARIANTS,
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl<'de> _serde::Deserialize<'de> for __Field {
|
|
|
|
#[inline]
|
2021-01-08 21:35:52 -06:00
|
|
|
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, T, U>
|
|
|
|
where
|
|
|
|
T: _serde::Deserialize<'de>,
|
|
|
|
U: _serde::Deserialize<'de>,
|
|
|
|
{
|
2021-01-08 21:35:52 -06:00
|
|
|
marker: _serde::__private::PhantomData<GenericEnum<T, U>>,
|
|
|
|
lifetime: _serde::__private::PhantomData<&'de ()>,
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
impl<'de, T, U> _serde::de::Visitor<'de> for __Visitor<'de, T, U>
|
|
|
|
where
|
|
|
|
T: _serde::Deserialize<'de>,
|
|
|
|
U: _serde::Deserialize<'de>,
|
|
|
|
{
|
|
|
|
type Value = GenericEnum<T, U>;
|
|
|
|
fn expecting(
|
|
|
|
&self,
|
2021-01-08 21:35:52 -06:00
|
|
|
__formatter: &mut _serde::__private::Formatter,
|
|
|
|
) -> _serde::__private::fmt::Result {
|
|
|
|
_serde::__private::Formatter::write_str(__formatter, "enum GenericEnum")
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
fn visit_enum<__A>(
|
|
|
|
self,
|
|
|
|
__data: __A,
|
2021-01-08 21:35:52 -06:00
|
|
|
) -> _serde::__private::Result<Self::Value, __A::Error>
|
2019-10-31 13:32:34 -05:00
|
|
|
where
|
|
|
|
__A: _serde::de::EnumAccess<'de>,
|
|
|
|
{
|
|
|
|
match match _serde::de::EnumAccess::variant(__data) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(__val) => __val,
|
|
|
|
_serde::__private::Err(__err) => {
|
|
|
|
return _serde::__private::Err(__err);
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
} {
|
|
|
|
(__Field::__field0, __variant) => {
|
|
|
|
match _serde::de::VariantAccess::unit_variant(__variant) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(__val) => __val,
|
|
|
|
_serde::__private::Err(__err) => {
|
|
|
|
return _serde::__private::Err(__err);
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
};
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(GenericEnum::Unit)
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
2021-01-08 21:35:52 -06:00
|
|
|
(__Field::__field1, __variant) => _serde::__private::Result::map(
|
2019-10-31 13:32:34 -05:00
|
|
|
_serde::de::VariantAccess::newtype_variant::<T>(__variant),
|
|
|
|
GenericEnum::NewType,
|
|
|
|
),
|
|
|
|
(__Field::__field2, __variant) => {
|
|
|
|
struct __Visitor<'de, T, U>
|
|
|
|
where
|
|
|
|
T: _serde::Deserialize<'de>,
|
|
|
|
U: _serde::Deserialize<'de>,
|
|
|
|
{
|
2021-01-08 21:35:52 -06:00
|
|
|
marker: _serde::__private::PhantomData<GenericEnum<T, U>>,
|
|
|
|
lifetime: _serde::__private::PhantomData<&'de ()>,
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
impl<'de, T, U> _serde::de::Visitor<'de> for __Visitor<'de, T, U>
|
|
|
|
where
|
|
|
|
T: _serde::Deserialize<'de>,
|
|
|
|
U: _serde::Deserialize<'de>,
|
|
|
|
{
|
|
|
|
type Value = GenericEnum<T, U>;
|
|
|
|
fn expecting(
|
|
|
|
&self,
|
2021-01-08 21:35:52 -06:00
|
|
|
__formatter: &mut _serde::__private::Formatter,
|
|
|
|
) -> _serde::__private::fmt::Result
|
|
|
|
{
|
|
|
|
_serde::__private::Formatter::write_str(
|
2019-10-31 13:32:34 -05:00
|
|
|
__formatter,
|
|
|
|
"tuple variant GenericEnum::Seq",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
#[inline]
|
|
|
|
fn visit_seq<__A>(
|
|
|
|
self,
|
|
|
|
mut __seq: __A,
|
2021-01-08 21:35:52 -06:00
|
|
|
) -> _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::<
|
|
|
|
T,
|
|
|
|
>(
|
|
|
|
&mut __seq
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(__val) => __val,
|
|
|
|
_serde::__private::Err(__err) => {
|
|
|
|
return _serde::__private::Err(__err);
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
} {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Some(__value) => __value,
|
|
|
|
_serde::__private::None => {
|
|
|
|
return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (0usize , & "tuple variant GenericEnum::Seq with 2 elements")) ;
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
let __field1 = match match _serde::de::SeqAccess::next_element::<
|
|
|
|
U,
|
|
|
|
>(
|
|
|
|
&mut __seq
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(__val) => __val,
|
|
|
|
_serde::__private::Err(__err) => {
|
|
|
|
return _serde::__private::Err(__err);
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
} {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Some(__value) => __value,
|
|
|
|
_serde::__private::None => {
|
|
|
|
return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (1usize , & "tuple variant GenericEnum::Seq with 2 elements")) ;
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
};
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(GenericEnum::Seq(__field0, __field1))
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_serde::de::VariantAccess::tuple_variant(
|
|
|
|
__variant,
|
|
|
|
2usize,
|
|
|
|
__Visitor {
|
2021-01-08 21:35:52 -06:00
|
|
|
marker: _serde::__private::PhantomData::<GenericEnum<T, U>>,
|
|
|
|
lifetime: _serde::__private::PhantomData,
|
2019-10-31 13:32:34 -05:00
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
(__Field::__field3, __variant) => {
|
|
|
|
#[allow(non_camel_case_types)]
|
|
|
|
enum __Field {
|
|
|
|
__field0,
|
|
|
|
__field1,
|
|
|
|
__ignore,
|
|
|
|
}
|
|
|
|
struct __FieldVisitor;
|
|
|
|
impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
|
|
|
|
type Value = __Field;
|
|
|
|
fn expecting(
|
|
|
|
&self,
|
2021-01-08 21:35:52 -06:00
|
|
|
__formatter: &mut _serde::__private::Formatter,
|
|
|
|
) -> _serde::__private::fmt::Result
|
|
|
|
{
|
|
|
|
_serde::__private::Formatter::write_str(
|
2019-10-31 13:32:34 -05:00
|
|
|
__formatter,
|
|
|
|
"field identifier",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
fn visit_u64<__E>(
|
|
|
|
self,
|
|
|
|
__value: u64,
|
2021-01-08 21:35:52 -06:00
|
|
|
) -> _serde::__private::Result<Self::Value, __E>
|
2019-10-31 13:32:34 -05:00
|
|
|
where
|
|
|
|
__E: _serde::de::Error,
|
|
|
|
{
|
|
|
|
match __value {
|
2021-01-08 21:35:52 -06:00
|
|
|
0u64 => _serde::__private::Ok(__Field::__field0),
|
|
|
|
1u64 => _serde::__private::Ok(__Field::__field1),
|
2021-01-23 21:45:15 -06:00
|
|
|
_ => _serde::__private::Ok(__Field::__ignore),
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fn visit_str<__E>(
|
|
|
|
self,
|
|
|
|
__value: &str,
|
2021-01-08 21:35:52 -06:00
|
|
|
) -> _serde::__private::Result<Self::Value, __E>
|
2019-10-31 13:32:34 -05:00
|
|
|
where
|
|
|
|
__E: _serde::de::Error,
|
|
|
|
{
|
|
|
|
match __value {
|
2021-01-08 21:35:52 -06:00
|
|
|
"x" => _serde::__private::Ok(__Field::__field0),
|
|
|
|
"y" => _serde::__private::Ok(__Field::__field1),
|
|
|
|
_ => _serde::__private::Ok(__Field::__ignore),
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
fn visit_bytes<__E>(
|
|
|
|
self,
|
|
|
|
__value: &[u8],
|
2021-01-08 21:35:52 -06:00
|
|
|
) -> _serde::__private::Result<Self::Value, __E>
|
2019-10-31 13:32:34 -05:00
|
|
|
where
|
|
|
|
__E: _serde::de::Error,
|
|
|
|
{
|
|
|
|
match __value {
|
2021-01-08 21:35:52 -06:00
|
|
|
b"x" => _serde::__private::Ok(__Field::__field0),
|
|
|
|
b"y" => _serde::__private::Ok(__Field::__field1),
|
|
|
|
_ => _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,
|
2021-01-08 21:35:52 -06:00
|
|
|
) -> _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, T, U>
|
|
|
|
where
|
|
|
|
T: _serde::Deserialize<'de>,
|
|
|
|
U: _serde::Deserialize<'de>,
|
|
|
|
{
|
2021-01-08 21:35:52 -06:00
|
|
|
marker: _serde::__private::PhantomData<GenericEnum<T, U>>,
|
|
|
|
lifetime: _serde::__private::PhantomData<&'de ()>,
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
impl<'de, T, U> _serde::de::Visitor<'de> for __Visitor<'de, T, U>
|
|
|
|
where
|
|
|
|
T: _serde::Deserialize<'de>,
|
|
|
|
U: _serde::Deserialize<'de>,
|
|
|
|
{
|
|
|
|
type Value = GenericEnum<T, U>;
|
|
|
|
fn expecting(
|
|
|
|
&self,
|
2021-01-08 21:35:52 -06:00
|
|
|
__formatter: &mut _serde::__private::Formatter,
|
|
|
|
) -> _serde::__private::fmt::Result
|
|
|
|
{
|
|
|
|
_serde::__private::Formatter::write_str(
|
2019-10-31 13:32:34 -05:00
|
|
|
__formatter,
|
|
|
|
"struct variant GenericEnum::Map",
|
|
|
|
)
|
|
|
|
}
|
|
|
|
#[inline]
|
|
|
|
fn visit_seq<__A>(
|
|
|
|
self,
|
|
|
|
mut __seq: __A,
|
2021-01-08 21:35:52 -06:00
|
|
|
) -> _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::<
|
|
|
|
T,
|
|
|
|
>(
|
|
|
|
&mut __seq
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(__val) => __val,
|
|
|
|
_serde::__private::Err(__err) => {
|
|
|
|
return _serde::__private::Err(__err);
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
} {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Some(__value) => __value,
|
|
|
|
_serde::__private::None => {
|
|
|
|
return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (0usize , & "struct variant GenericEnum::Map with 2 elements")) ;
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
let __field1 = match match _serde::de::SeqAccess::next_element::<
|
|
|
|
U,
|
|
|
|
>(
|
|
|
|
&mut __seq
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(__val) => __val,
|
|
|
|
_serde::__private::Err(__err) => {
|
|
|
|
return _serde::__private::Err(__err);
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
} {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Some(__value) => __value,
|
|
|
|
_serde::__private::None => {
|
|
|
|
return _serde :: __private :: Err (_serde :: de :: Error :: invalid_length (1usize , & "struct variant GenericEnum::Map with 2 elements")) ;
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
};
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(GenericEnum::Map {
|
2019-10-31 13:32:34 -05:00
|
|
|
x: __field0,
|
|
|
|
y: __field1,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
#[inline]
|
|
|
|
fn visit_map<__A>(
|
|
|
|
self,
|
|
|
|
mut __map: __A,
|
2021-01-08 21:35:52 -06:00
|
|
|
) -> _serde::__private::Result<Self::Value, __A::Error>
|
2019-10-31 13:32:34 -05:00
|
|
|
where
|
|
|
|
__A: _serde::de::MapAccess<'de>,
|
|
|
|
{
|
2021-01-08 21:35:52 -06:00
|
|
|
let mut __field0: _serde::__private::Option<T> =
|
|
|
|
_serde::__private::None;
|
|
|
|
let mut __field1: _serde::__private::Option<U> =
|
|
|
|
_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)
|
|
|
|
{
|
2021-01-08 21:35:52 -06:00
|
|
|
_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 => {
|
2021-01-08 21:35:52 -06:00
|
|
|
if _serde::__private::Option::is_some(&__field0) {
|
|
|
|
return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("x")) ;
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
2021-01-08 21:35:52 -06:00
|
|
|
__field0 = _serde::__private::Some(
|
2019-10-31 13:32:34 -05:00
|
|
|
match _serde::de::MapAccess::next_value::<T>(
|
|
|
|
&mut __map,
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(__val) => __val,
|
|
|
|
_serde::__private::Err(__err) => {
|
|
|
|
return _serde::__private::Err(__err);
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
__Field::__field1 => {
|
2021-01-08 21:35:52 -06:00
|
|
|
if _serde::__private::Option::is_some(&__field1) {
|
|
|
|
return _serde :: __private :: Err (< __A :: Error as _serde :: de :: Error > :: duplicate_field ("y")) ;
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
2021-01-08 21:35:52 -06:00
|
|
|
__field1 = _serde::__private::Some(
|
2019-10-31 13:32:34 -05:00
|
|
|
match _serde::de::MapAccess::next_value::<U>(
|
|
|
|
&mut __map,
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_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
|
|
|
|
) {
|
2021-01-08 21:35:52 -06:00
|
|
|
_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 {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Some(__field0) => __field0,
|
|
|
|
_serde::__private::None => {
|
|
|
|
match _serde::__private::de::missing_field("x") {
|
|
|
|
_serde::__private::Ok(__val) => __val,
|
|
|
|
_serde::__private::Err(__err) => {
|
|
|
|
return _serde::__private::Err(__err);
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
let __field1 = match __field1 {
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Some(__field1) => __field1,
|
|
|
|
_serde::__private::None => {
|
|
|
|
match _serde::__private::de::missing_field("y") {
|
|
|
|
_serde::__private::Ok(__val) => __val,
|
|
|
|
_serde::__private::Err(__err) => {
|
|
|
|
return _serde::__private::Err(__err);
|
2019-10-31 13:32:34 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2021-01-08 21:35:52 -06:00
|
|
|
_serde::__private::Ok(GenericEnum::Map {
|
2019-10-31 13:32:34 -05:00
|
|
|
x: __field0,
|
|
|
|
y: __field1,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const FIELDS: &'static [&'static str] = &["x", "y"];
|
|
|
|
_serde::de::VariantAccess::struct_variant(
|
|
|
|
__variant,
|
|
|
|
FIELDS,
|
|
|
|
__Visitor {
|
2021-01-08 21:35:52 -06:00
|
|
|
marker: _serde::__private::PhantomData::<GenericEnum<T, U>>,
|
|
|
|
lifetime: _serde::__private::PhantomData,
|
2019-10-31 13:32:34 -05:00
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const VARIANTS: &'static [&'static str] = &["Unit", "NewType", "Seq", "Map"];
|
|
|
|
_serde::Deserializer::deserialize_enum(
|
|
|
|
__deserializer,
|
|
|
|
"GenericEnum",
|
|
|
|
VARIANTS,
|
|
|
|
__Visitor {
|
2021-01-08 21:35:52 -06:00
|
|
|
marker: _serde::__private::PhantomData::<GenericEnum<T, U>>,
|
|
|
|
lifetime: _serde::__private::PhantomData,
|
2019-10-31 13:32:34 -05:00
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2019-11-03 06:08:39 -06:00
|
|
|
};
|