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).

Copy link
Owner

@Peternator7 Peternator7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@Peternator7 Peternator7 merged commit bc8fa93 into Peternator7:master Nov 24, 2019
@Peternator7
Copy link
Owner

Looks good! Merged

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.

2 participants