-
Notifications
You must be signed in to change notification settings - Fork 152
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
minimal extraction of enum_metadata from PR #207. #208
base: master
Are you sure you want to change the base?
Conversation
It seems like github's diff comparison doesn't pick up on the fact that macros/enum_metadata.rs is a copy of enum_fromrepr.rs with 70% similarity, but viewing in another diff tool like gitk should be helpful when getting rid of duplicated code. |
So, I took a first pass at this, somehow my attempt to move out the duplicated code ended up longer than the combined duplication. Edit: Turns out that was wrong, and I can use this macro as-is in my crate, |
This uses MetadataImpl in enum_count and enum_variant_names, in addition to enum_metadata, and from_repr from the previous commits.
Wonder if we should include a |
This is the minimal extraction of
EnumMetadata
, which excisesOpaqueRepr
from my pr #207.It doesn't yet fix the duplicate code issue, I also think there is a function in #183 which this hadn't implemented.
I need to work on the other crate where the stuff which was excised goes however,
So If anyone wants to pick this up, by all means.
I assume what needs to be done is pull as much as we can out into
strum_macros/helpers/
and then call those from the various..._inner(..)
calls. Instead of just duplicating everything. But note that the types and constness between the inherent and trait impl may differ making it difficult to remove all duplication.Otherwise i'll try and get back to this when I can -- or we can close it and reopen at that time!