rust-lang / rust-lang/reference

Assignee expressions can be enums

Open Beginner friendly
#2,280 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

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".

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the assignee expressions section of the Rust Reference linked in the issue, and read issue #2208 for related context. Compare the documented struct rule with the enum examples shown here, then update the reference so the supported enum case and its irrefutability condition are accurately described.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.