Skip to content

Commit

Permalink
Add support for internally tagged enums in non self-describing formats
Browse files Browse the repository at this point in the history
Deserializer methods are only hints which deserializer is not obliged to follow.
Both TaggedContentVisitor and InternallyTaggedUnitVisitor accepts only
visit_map and visit_seq and that is what derived implementation of Deserialize
does for structs. Therefore it is fine to call deserialize_map here, as that
already did in derived deserialize implementation
  • Loading branch information
Mingun committed Aug 12, 2023
1 parent 1006028 commit 3ea3cc4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions serde_derive/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ fn deserialize_internally_tagged_enum(

#variants_stmt

let (__tag, __content) = _serde::Deserializer::deserialize_any(
let (__tag, __content) = _serde::Deserializer::deserialize_map(
__deserializer,
_serde::__private::de::TaggedContentVisitor::<__Field>::new(#tag, #expecting))?;
let __deserializer = _serde::__private::de::ContentDeserializer::<__D::Error>::new(__content);
Expand Down Expand Up @@ -1840,7 +1840,7 @@ fn deserialize_internally_tagged_variant(
quote!((#default))
});
quote_block! {
_serde::Deserializer::deserialize_any(#deserializer, _serde::__private::de::InternallyTaggedUnitVisitor::new(#type_name, #variant_name))?;
_serde::Deserializer::deserialize_map(#deserializer, _serde::__private::de::InternallyTaggedUnitVisitor::new(#type_name, #variant_name))?;
_serde::__private::Ok(#this_value::#variant_ident #default)
}
}
Expand Down

0 comments on commit 3ea3cc4

Please sign in to comment.