Skip to content

feat: @default enum field #2361

@carlocorradini

Description

@carlocorradini

It would be very useful to be able to specify a default value for an enum field.

In the example below, MyEnum has a default literal value of A.
The struct MyStruct has two fields: the first, a, has a custom default set explicitly to MyEnum::C, while the second, b, uses the enum’s default literal value MyEnum::A.

enum MyEnum {
    @default_literal
    A,
    B,
    C
};

struct MyStruct {
    @default(MyEnum::C)
    MyEnum a;
    MyEnum b;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions