Merge pull request #1228 from serde-rs/untagged

Reduce instantiations of Result::map in Deserialize of unit variants
This commit is contained in:
David Tolnay 2018-04-21 13:46:36 -07:00 committed by GitHub
commit b07a208716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1626,12 +1626,13 @@ fn deserialize_untagged_variant(
let type_name = params.type_name(); let type_name = params.type_name();
let variant_name = variant.ident.as_ref(); let variant_name = variant.ident.as_ref();
quote_expr! { quote_expr! {
_serde::export::Result::map( match _serde::Deserializer::deserialize_any(
_serde::Deserializer::deserialize_any( #deserializer,
#deserializer, _serde::private::de::UntaggedUnitVisitor::new(#type_name, #variant_name)
_serde::private::de::UntaggedUnitVisitor::new(#type_name, #variant_name) ) {
), _serde::export::Ok(()) => _serde::export::Ok(#this::#variant_ident),
|()| #this::#variant_ident) _serde::export::Err(__err) => _serde::export::Err(__err),
}
} }
} }
Style::Newtype => deserialize_untagged_newtype_variant( Style::Newtype => deserialize_untagged_newtype_variant(