Skip to content

Feature Request: fn new for enums #60

Description

@Lucretiel

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}}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions