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

Feature/33/derive enum variants #34

Merged

Conversation

azriel91
Copy link
Contributor

@azriel91 azriel91 commented Sep 19, 2018

Implemented #33.
there's an error that I can't work out, see commit 429040a, uncommenting that code causes the compiler to panic (it doesn't find the strum attribute, even though it's clearly defined). Fixed it.

This branch was branched off #32, so it's a bit noisy from that.

@azriel91 azriel91 force-pushed the feature/33/derive-enum-variants branch from 429040a to 0091ac7 Compare September 19, 2018 21:34
@azriel91
Copy link
Contributor Author

Solved the issue I hit earlier and added docs, phew. Also allow the user to rename the generated enum.

@azriel91
Copy link
Contributor Author

okay, finally got this working:

#[strum_discriminants(
    // These attributes are specifically looked for
    name(MyVariants),
    derive(EnumIter, ToString),
    // --- Any additional attributes are passed through to the derived enum
    strum(serialize = "snake_case"),
)]
enum MyEnum { A }

// generates
#[derive(Clone, Copy, Debug, PartialEq, Eq, EnumIter, ToString)]
#[strum(serialize = "snake_case")]
enum MyVariants { A }

@azriel91 azriel91 force-pushed the feature/33/derive-enum-variants branch from ab2751a to 236f41d Compare September 20, 2018 07:28
@azriel91 azriel91 force-pushed the feature/33/derive-enum-variants branch from 44087a9 to 58ce968 Compare September 24, 2018 02:15
@azriel91 azriel91 force-pushed the feature/33/derive-enum-variants branch from 58ce968 to f92a81a Compare September 24, 2018 09:08
@Peternator7 Peternator7 merged commit 1c00f6c into Peternator7:master Sep 26, 2018
@azriel91 azriel91 deleted the feature/33/derive-enum-variants branch September 26, 2018 19:33
@Peternator7
Copy link
Owner

Changes available on crates.io :) Thanks for all your help on this!!

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.

None yet

2 participants