Skip to content

Commit 0d69d8d

Browse files
authored
Merge pull request #146 from Lucretiel/document-identifier-enums
Add documentation for `variant_identifier` and `field_identifier`
2 parents 1a9493e + 0de9c89 commit 0d69d8d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

_src/container-attrs.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@
6969
Use the untagged enum representation for this enum. See [enum
7070
representations](enum-representations.md) for details on this representation.
7171

72+
- ##### `#[serde(variant_identifier)]` {#variant--identifier}
73+
74+
Use an identifier representation for this enum. This can only be applied to enums that are C-like (containing only unit variants), and forces them to always be represented as strings, regardless of the underlying data format's representation of enums.
75+
76+
- ##### `#[serde(field_identifier)]` {#field--identifier}
77+
78+
Identical to [`variant_identifier`](#variant--identifier), but also allows for the last variant to be a newtype variant, which will be used if none of the other variants match (similar to [`#[serde(other)]`](../variant-attrs.html#other)). Like `variant_identifier`, this forces the enum to always be represented as a string, regardless of the underlying data format's representation of enums.
79+
7280
- ##### `#[serde(bound = "T: MyTrait")]` {#bound}
7381

7482
Where-clause for the `Serialize` and `Deserialize` impls. This replaces any

0 commit comments

Comments
 (0)