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 Request: fn new for enums #60

Open
Lucretiel opened this issue Mar 20, 2023 · 0 comments
Open

Feature Request: fn new for enums #60

Lucretiel opened this issue Mar 20, 2023 · 0 comments

Comments

@Lucretiel
Copy link
Contributor

While I see that derive-new can create a collection of constructors for enum variants, it would be convenient for enums that always have a single new constructor, like this:

#[derive(new)]
enum Foo {
    #[new]
    InitialState { data: String },
    SecondState{ data: Vec<u8> }
}

// Produces:

fn new(data: String) -> Foo { Foo::InitialState{data}}
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

No branches or pull requests

1 participant