Simplify implementation of flattened internally tagged enum

The fact that the tag entry is consumed was only observable if there is
a later flattened map field, at which point the behavior is already
confusing anyway.

    #[derive(Deserialize)]
    struct Example {
        #[serde(flatten)]
        a: InternallyTagged,
        #[serde(flatten)]
        rest: BTreeMap<String, Value>,
    }

Before this simplification the map would receive all the fields of the
internally tagged enum but not its tag, after it receives all the fields
including the tag.
This commit is contained in:
David Tolnay
2018-05-05 22:30:41 -07:00
parent d8120e19bc
commit aac1c65033
3 changed files with 13 additions and 54 deletions
+1 -2
View File
@@ -1195,8 +1195,7 @@ fn deserialize_internally_tagged_enum(
let __tagged = try!(_serde::Deserializer::private_deserialize_internally_tagged_enum(
__deserializer,
_serde::private::de::TaggedContentVisitor::<__Field>::new(#tag),
#tag));
_serde::private::de::TaggedContentVisitor::<__Field>::new(#tag)));
match __tagged.tag {
#(#variant_arms)*