Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support deserializing a flattened internally tagged enum #1245

Merged
merged 2 commits into from
May 6, 2018
Merged

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented May 6, 2018

Fixes #1189.

@dtolnay dtolnay requested a review from mitsuhiko May 6, 2018 04:43
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.
@dtolnay dtolnay merged commit 6374467 into master May 6, 2018
@dtolnay dtolnay deleted the flat branch May 6, 2018 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant