Add attributes to strum_discriminants for custom attributes in generated discriminant enum#320
Draft
0x5abe wants to merge 3 commits intoPeternator7:masterfrom
Draft
Add attributes to strum_discriminants for custom attributes in generated discriminant enum#3200x5abe wants to merge 3 commits intoPeternator7:masterfrom
attributes to strum_discriminants for custom attributes in generated discriminant enum#3200x5abe wants to merge 3 commits intoPeternator7:masterfrom
Conversation
…llow for custom attributes before the derives in the discriminant enum
Owner
|
Hey @SabeMP, I'd suggest the following. If we can find an example with Also, could you undo the formatting changes? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
EnumDiscriminantsderive 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.