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

field_identifier and variant_identifier container attributes #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions _src/container-attrs.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,28 @@
Specify a path to the `serde` crate instance to use when referring to Serde
APIs from generated code. This is normally only applicable when invoking
re-exported Serde derives from a public macro in a different crate.

- ##### `#[serde(field_identifier)]` {#field_identifier}

Denotes that this enum represents the field names of a struct type. Used when
[manually implementing `Deserialize` for the struct
type.](deserialize_struct.md)

This attribute is probably not useful if you are automatically deriving your
own types.

Variants for the field_identifier enum may either all be units, or the last
variant may be a newtype struct, which is selected when an unlisted field name
is encountered during deserialization. Cannot be set if
`#[serde(variant_identifier)]` is also set.

- ##### `#[serde(variant_identifier)]` {#variant_identifier}

Denotes that this enum represents the variant names of another enum type.
Used when manually implementing `Deserialize` for the other enum type.

This attribute is probably not useful if you are automatically deriving your
own types.

Only valid for enums where all variants are units. Cannot be set if
`#[serde(field_identifier)]` is also set.