rust-lang / rust-lang/reference
Assignee expressions can be enums
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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