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 committed 2021-01-23 20:04:58 -08:00
1 parent 84ad76b2e5
commit b6a2d07f26
2 files changed
+26 -16

No files matched your search

+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)