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

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

Merged
merged 4 commits into from Dec 28, 2018
Merged

Conversation

jwillbold
Copy link
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
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
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.

None yet

2 participants