Skip to content

Feature Request: Derive Default from Enum Variant #6860

@mitsuhiko

Description

@mitsuhiko

A relatively common situation for me is an enum that has one variant that should become the default. It would be nice if one could select the variant that should become the default and be able to automatically derive a Default for it:

enum Variant {
    Undefined, // hover and "derive Default for this variant"
    Minor,
    Major,
}

Would then produce this:

impl Default for Variant {
    fn default() -> Variant {
        Variant::Undefined
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions