Format PR #1917 with rustfmt 1.4.32
This commit is contained in:
parent
ba46f45dc5
commit
60e08f9545
@ -1,7 +1,7 @@
|
|||||||
use lib::*;
|
use lib::*;
|
||||||
|
|
||||||
|
use de::value::{BorrowedBytesDeserializer, BytesDeserializer};
|
||||||
use de::{Deserialize, DeserializeSeed, Deserializer, Error, IntoDeserializer, Visitor};
|
use de::{Deserialize, DeserializeSeed, Deserializer, Error, IntoDeserializer, Visitor};
|
||||||
use de::value::{BytesDeserializer, BorrowedBytesDeserializer};
|
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
use de::{MapAccess, Unexpected};
|
use de::{MapAccess, Unexpected};
|
||||||
|
@ -1893,15 +1893,12 @@ fn deserialize_generated_identifier(
|
|||||||
let fallthrough = quote!(_serde::__private::Ok(__Field::__other(__value)));
|
let fallthrough = quote!(_serde::__private::Ok(__Field::__other(__value)));
|
||||||
(
|
(
|
||||||
Some(ignore_variant),
|
Some(ignore_variant),
|
||||||
Some((fallthrough.clone(), fallthrough))
|
Some((fallthrough.clone(), fallthrough)),
|
||||||
)
|
)
|
||||||
} else if let Some(other_idx) = other_idx {
|
} else if let Some(other_idx) = other_idx {
|
||||||
let ignore_variant = fields[other_idx].1.clone();
|
let ignore_variant = fields[other_idx].1.clone();
|
||||||
let fallthrough = quote!(_serde::__private::Ok(__Field::#ignore_variant));
|
let fallthrough = quote!(_serde::__private::Ok(__Field::#ignore_variant));
|
||||||
(
|
(None, Some((fallthrough.clone(), fallthrough)))
|
||||||
None,
|
|
||||||
Some((fallthrough.clone(), fallthrough))
|
|
||||||
)
|
|
||||||
} else if is_variant || cattrs.deny_unknown_fields() {
|
} else if is_variant || cattrs.deny_unknown_fields() {
|
||||||
(None, None)
|
(None, None)
|
||||||
} else {
|
} else {
|
||||||
@ -1909,7 +1906,7 @@ fn deserialize_generated_identifier(
|
|||||||
let fallthrough = quote!(_serde::__private::Ok(__Field::__ignore));
|
let fallthrough = quote!(_serde::__private::Ok(__Field::__ignore));
|
||||||
(
|
(
|
||||||
Some(ignore_variant),
|
Some(ignore_variant),
|
||||||
Some((fallthrough.clone(), fallthrough))
|
Some((fallthrough.clone(), fallthrough)),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1973,25 +1970,21 @@ fn deserialize_custom_identifier(
|
|||||||
if last.attrs.other() {
|
if last.attrs.other() {
|
||||||
let ordinary = &variants[..variants.len() - 1];
|
let ordinary = &variants[..variants.len() - 1];
|
||||||
let fallthrough = quote!(_serde::__private::Ok(#this::#last_ident));
|
let fallthrough = quote!(_serde::__private::Ok(#this::#last_ident));
|
||||||
(
|
(ordinary, Some((fallthrough.clone(), fallthrough)))
|
||||||
ordinary,
|
|
||||||
Some((fallthrough.clone(), fallthrough))
|
|
||||||
)
|
|
||||||
} else if let Style::Newtype = last.style {
|
} else if let Style::Newtype = last.style {
|
||||||
let ordinary = &variants[..variants.len() - 1];
|
let ordinary = &variants[..variants.len() - 1];
|
||||||
let fallthrough = |method| quote! {
|
let fallthrough = |method| {
|
||||||
_serde::__private::Result::map(
|
quote! {
|
||||||
_serde::Deserialize::deserialize(
|
_serde::__private::Result::map(
|
||||||
_serde::__private::de::IdentifierDeserializer::#method(__value)
|
_serde::Deserialize::deserialize(
|
||||||
),
|
_serde::__private::de::IdentifierDeserializer::#method(__value)
|
||||||
#this::#last_ident)
|
),
|
||||||
|
#this::#last_ident)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
(
|
(
|
||||||
ordinary,
|
ordinary,
|
||||||
Some((
|
Some((fallthrough(quote!(from)), fallthrough(quote!(borrowed)))),
|
||||||
fallthrough(quote!(from)),
|
|
||||||
fallthrough(quote!(borrowed)),
|
|
||||||
))
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
(variants, None)
|
(variants, None)
|
||||||
@ -2128,10 +2121,8 @@ fn deserialize_identifier(
|
|||||||
(None, None, None, None)
|
(None, None, None, None)
|
||||||
};
|
};
|
||||||
|
|
||||||
let (
|
let (fallthrough_arm, fallthrough_borrowed_arm) = if let Some(fallthrough) = fallthrough.clone()
|
||||||
fallthrough_arm,
|
{
|
||||||
fallthrough_borrowed_arm,
|
|
||||||
) = if let Some(fallthrough) = fallthrough.clone() {
|
|
||||||
fallthrough
|
fallthrough
|
||||||
} else if is_variant {
|
} else if is_variant {
|
||||||
let fallthrough = quote! {
|
let fallthrough = quote! {
|
||||||
|
@ -99,12 +99,7 @@ fn test_field_identifier() {
|
|||||||
Str(&'a str),
|
Str(&'a str),
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_de_tokens(
|
assert_de_tokens(&FieldStr::Str("value"), &[Token::BorrowedStr("value")]);
|
||||||
&FieldStr::Str("value"),
|
|
||||||
&[
|
|
||||||
Token::BorrowedStr("value"),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
|
|
||||||
#[derive(Deserialize, Debug, PartialEq)]
|
#[derive(Deserialize, Debug, PartialEq)]
|
||||||
#[serde(field_identifier)]
|
#[serde(field_identifier)]
|
||||||
@ -115,9 +110,7 @@ fn test_field_identifier() {
|
|||||||
|
|
||||||
assert_de_tokens(
|
assert_de_tokens(
|
||||||
&FieldBytes::Bytes(b"value"),
|
&FieldBytes::Bytes(b"value"),
|
||||||
&[
|
&[Token::BorrowedBytes(b"value")],
|
||||||
Token::BorrowedBytes(b"value"),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user