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

Add #[strum(transparent)] attribute #331

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

bobozaur
Copy link

@bobozaur bobozaur commented Feb 4, 2024

Adds the transparent attribute, usable with AsRefStr, Display and IntoStaticStr. This delegates the derived trait impl to the underlying (single) field of the enum variant.

Implementing this for EnumString would be nice, but it doesn't really act the same way as for the other traits. For EnumString, something like #[strum(other)] (similar to #[serde(other)]) would make more sense, because there you would have a last single attempt to parse the input into a catch all variant, whereas trasparent can be added to multiple variants.

Therefore, if desired, that should be handled in a separate PR.

Closes #258

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add #[strum(transparent)] argument
1 participant