|
138 | 138 |
|
139 | 139 | - ##### `#[serde(variant_identifier)]` {#variant_identifier}
|
140 | 140 |
|
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. |
145 | 146 |
|
146 | 147 | - ##### `#[serde(field_identifier)]` {#field_identifier}
|
147 | 148 |
|
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)`]. |
153 | 154 |
|
154 | 155 | [`variant_identifier`]: #variant_identifier
|
155 |
| - [`#[serde(other)`]: variant-attrs.md#other |
| 156 | + [`serde(other)`]: variant-attrs.md#other |
0 commit comments