minimal extraction of enum_metadata from PR #207.#208
minimal extraction of enum_metadata from PR #207.#208ratmice wants to merge 6 commits intoPeternator7:masterfrom
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 |
|
The original referenced PR was closed and this one was last updated in 2022. What is the status? Is this still relevant or needed?
❤️ If this isn't actively being worked on can it be closed? If you want to come back to it, I think it would benefit from a brand new PR with a self contained description explaining either what this is fixing (expected/actual disagreement) or what it's adding (can't do today versus with my feature you can). Can you close this PR? |
|
Sure this can be closed, It works fine, but never got reviewed. but I'll likely just rewrite that to avoid using strum, I never heard back after trying to minimize that in this patch... |
|
To answer your question about what this does that strum currently can't do today, beyond what is in that it also added an associated |
This is the minimal extraction of
EnumMetadata, which excisesOpaqueReprfrom 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!