Return IdentifierDeserializer to just one associated type

The BorrowedDeserializer was added in #1917, but only makes sense for
&str and &[u8], not for u64 which also needs to be have an
IdentifierDeserializer impl.
This commit is contained in:
David Tolnay
2021-01-23 20:00:07 -08:00
parent 84ad76b2e5
commit b6a2d07f26
2 changed files with 26 additions and 16 deletions
+6 -3
View File
@@ -1992,18 +1992,21 @@ fn deserialize_custom_identifier(
(ordinary, Some((fallthrough.clone(), fallthrough)))
} else if let Style::Newtype = last.style {
let ordinary = &variants[..variants.len() - 1];
let fallthrough = |method| {
let fallthrough = |value| {
quote! {
_serde::__private::Result::map(
_serde::Deserialize::deserialize(
_serde::__private::de::IdentifierDeserializer::#method(__value)
_serde::__private::de::IdentifierDeserializer::from(#value)
),
#this::#last_ident)
}
};
(
ordinary,
Some((fallthrough(quote!(from)), fallthrough(quote!(borrowed)))),
Some((
fallthrough(quote!(__value)),
fallthrough(quote!(_serde::__private::de::Borrowed(__value))),
)),
)
} else {
(variants, None)