serde
serde copied to clipboard
Allow only one unit variant in untagged enums
We cannot distinguish between them when deserialize, so prohibit that to protect from possible errors.
If you really need several unit variants, mark all of them except one with #[serde(skip_deserializing)].
Several units still are allowed for serialization, because that will allow to add to the enums new preferred unit variant and deprecate the old without breaking changes. Both (new and old) would be serialized to the same value, but deserialization will get you only new variant.