Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[serde_derive] Is there a way to derive my own "None" variant? #2313

Closed
vidhanio opened this issue Nov 5, 2022 · 1 comment
Closed

[serde_derive] Is there a way to derive my own "None" variant? #2313

vidhanio opened this issue Nov 5, 2022 · 1 comment

Comments

@vidhanio
Copy link

vidhanio commented Nov 5, 2022

I have an enum with a few variants, and I would like one of them to behave as None would, deserializing to and from it if a null is encountered. Is this possible with serde_derive?

@vidhanio vidhanio changed the title [serde_derive] Is there a way to derive my own "None" variant? [serde_derive] Is there a way to derive my own "None" variant? Nov 5, 2022
@mountainfloating
Copy link

Take a look at the docs of field attributes: https://serde.rs/field-attrs.html They're very well documented! Maybe default is, what you're looking for.

@vidhanio vidhanio closed this as completed Dec 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants