serde icon indicating copy to clipboard operation
serde copied to clipboard

Allow only one unit variant in untagged enums

Open Mingun opened this issue 6 months ago • 0 comments

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.

Mingun avatar May 31 '25 11:05 Mingun