Skip to content

Allow #[serde(tag="...")] on structs#1448

Merged
dtolnay merged 4 commits intoserde-rs:masterfrom
jwillbold:master
Dec 28, 2018
Merged

Allow #[serde(tag="...")] on structs#1448
dtolnay merged 4 commits intoserde-rs:masterfrom
jwillbold:master

Conversation

@jwillbold
Copy link
Copy Markdown
Contributor

This is a patch to address #760 to allow #[serde(tag="...")] on structs. I guess, this patch would require a change in the docs, so it is still WIP.

Added test test_internally_tagged_struct.
Renamed EnumTag to TagType as it now also used for structs.
Modified serialize_struct_as_struct.
Removed ui/enum-representation/internally-tagged-struct test

Added test test_internally_tagged_struct
Renamed EnumTag to TagType as it now also used for structs 
Modified serialize_struct_as_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.

Nice. Please limit this to structs with named fields and add a ui test checking the error message when a tag attribute is given on a tuple struct or unit struct.

    
Added ui test struct-representation/internally-tagged-unit
Added ui test struct-representation/internally-tagged-tuple
    
Limited the serde(tag = "...") to enums and structs with named field
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!

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