Skip to content

Commit 22ab3c6

Browse files
committed
Rewrite variant_identifier and field_identifier explanation
1 parent 25d147c commit 22ab3c6

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

_src/container-attrs.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,19 @@
138138

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

141-
Use an identifier representation for this enum. This can only be applied to
142-
enums that are C-like (containing only unit variants), and forces them to
143-
always be represented as strings, regardless of the underlying data format's
144-
representation of enums.
141+
Deserialize either a string or an integer, depending on which one the data
142+
format uses as its representation of externally tagged enum variant tags.
143+
Generally human-readable formats would represent variants using their string
144+
name while compact binary formats would represent them using an integer index.
145+
This attribute can only be applied to an enum containing all unit variants.
145146

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

148-
Identical to [`variant_identifier`], but also allows for the last variant to
149-
be a newtype variant, which will be used if none of the other variants match
150-
(similar to [`#[serde(other)]`]). Like `variant_identifier`, this forces the
151-
enum to always be represented as a string, regardless of the underlying data
152-
format's representation of enums.
149+
Deserialize either a string or an integer, depending on which one the data
150+
format uses as its representation of struct fields identifiers. This attribute
151+
differs from [`variant_identifier`] in that the final variant is permitted to
152+
be a newtype variant, which will be deserialized if the input matches none of
153+
the unit variants of this enum, similar to [`serde(other)`].
153154

154155
[`variant_identifier`]: #variant_identifier
155-
[`#[serde(other)`]: variant-attrs.md#other
156+
[`serde(other)`]: variant-attrs.md#other

0 commit comments

Comments
 (0)