Uh oh!
There was an error while loading. Please reload this page.
[r+] Add enum discriminants to the reference. - #21047
Conversation
rust-highfive
commented
Jan 12, 2015
(rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Enums always have a discriminant, this syntax just lets you specify exactly what it is. They'll default to 0, 1, 2, ...
steveklabnik
commented
Jan 13, 2015
@sfackler addressed |
There was a problem hiding this comment.
One last nit: you can only do this if the enum is C-like, i.e. none of the variants have any data attached. For example, you can't do None as u32.
There was a problem hiding this comment.
C-like, i.e. none of the variants have any data attached.
By "C-like" you mean none like Foo(i32), yes? They all need to be Foo?
There was a problem hiding this comment.
Yep! PR #20907 adds an intrinsic to extract he discriminant from any enum, but its only intended to be used as an optimization for things like PartialEq implementations.
nikomatsakis
commented
Jan 14, 2015
r+ with @sfackler 's nit addressed |
[r+] Add enum discriminants to the reference. Reviewed-by: nikomatsakis
[r+] Add enum discriminants to the reference. Reviewed-by: nikomatsakis
steveklabnik
commented
Jan 17, 2015
Doing this manually as part of #21300 |
Add `unsafe(…)` attribute completion
Fixes#15755