Skip to content

Conversation

Mingun
Copy link
Contributor

@Mingun Mingun commented May 31, 2025

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 Mingun force-pushed the only-one-unit-variant-in-untagged-enum branch from 8707d4d to cf668e3 Compare June 15, 2025 10:28
…inguish between them when deserialize

If you really need several unit variants, mark all of them except one with `#[serde(skip_deserializing)]`
@Mingun Mingun force-pushed the only-one-unit-variant-in-untagged-enum branch from cf668e3 to 756e2ac Compare September 16, 2025 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant