Skip to content

Fix internally tagged enum deserialization with unknown fields#1376

Merged
dtolnay merged 2 commits intoserde-rs:masterfrom
dreid:fix-internally-tagged-enum-deserialization-with-unknown-fields
Sep 7, 2018
Merged

Fix internally tagged enum deserialization with unknown fields#1376
dtolnay merged 2 commits intoserde-rs:masterfrom
dreid:fix-internally-tagged-enum-deserialization-with-unknown-fields

Conversation

@dreid
Copy link
Copy Markdown
Contributor

@dreid dreid commented Sep 6, 2018

Currently an internally tagged enum with a unit variant will fail to deserialize if the map contains unknown fields.

Example on Playground

This change attempts to address that by having the InternallyTaggedUnitVisitor.visit_map method consume the map before returning.

I've added a test case for the simple enum case and for the case where the unit enum variant is flattened into a struct.

Copy link
Copy Markdown
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, nicely done.

@dtolnay dtolnay merged commit 8d5cda8 into serde-rs:master Sep 7, 2018
@dtolnay
Copy link
Copy Markdown
Member

dtolnay commented Sep 7, 2018

I released this fix in 1.0.77.

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.

2 participants