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

Move EnumVariantsNames into a trait which the macro implements #74

Merged
merged 2 commits into from Nov 24, 2019

Conversation

@Spanfile
Copy link
Contributor

@Spanfile Spanfile commented Nov 2, 2019

I ran into a case where I had to accept a generic parameter of any enum type that has the variants() function implemented, which would've previously required some awkward workarounds. This PR moves the function into its own trait VariantNames and changes the EnumVariantNames to implement it, so that it is possible to use the trait to accept any such enum (see the added test case).

…iantNames macro implements
Copy link
Owner

@Peternator7 Peternator7 left a comment

Thanks for this PR! This is a breaking change, but I generally prefer methods to be attached to traits so I'm happy to change it.

There's a few small changes, but it otherwise looks great!

strum_macros/src/macros/enum_variant_names.rs Outdated Show resolved Hide resolved
@Spanfile Spanfile requested a review from Peternator7 Nov 22, 2019
@Peternator7 Peternator7 merged commit bc8fa93 into Peternator7:master Nov 24, 2019
1 check passed
1 check passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@Peternator7
Copy link
Owner

@Peternator7 Peternator7 commented Nov 24, 2019

Looks good! Merged

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

Successfully merging this pull request may close these issues.

None yet

2 participants