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 attributes to strum_discriminants for custom attributes in generated discriminant enum #320

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

0x5abe
Copy link

@0x5abe 0x5abe commented Dec 23, 2023

Sometimes derive macros need a specific attribute to be above them to work properly. I ran across this while using bilge, where the TryFromBits derive macro requires the bitsize attribute above it. The EnumDiscriminants derive macro currently doesn't allow for arbitrary attribute macros before the generated enum's derives, so I added the #[strum_discriminants(attributes(..))] attribute to allow for this.

This PR is a draft because I am not entirely sure how a test for this specific attribute would be performed, and I wouldn't want it to get merged without its proper tests.

@Peternator7
Copy link
Owner

Hey @SabeMP, I'd suggest the following. If we can find an example with serde where this would be helpful, I'd be happy to add that as a dependency to the tests crate so we can validate this works consistently.

Also, could you undo the formatting changes?

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.

None yet

3 participants