Skip to content

Assignee expressions can be enums #2280

@theemathas

Description

@theemathas

See also #2208 for more on assignee expressions.

The following code compiles:

enum Never {}

enum Foo {
    Variant,
}

enum Bar {
    One,
    Two(Never),
}

fn main() {
    Foo::Variant = Foo::Variant;
    Bar::One = Bar::One;
}

However, the reference doesn't say that enums can be used in assignee expressions. It only mentions that structs can be used there.

But based on how the compiler behaves, it seems that enums can be used in assignee expressions, as long as it's "irrefutable".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions