Open
Description
I’ve recently been bouncing between Swift and Rust and have found the shorthand .variant
syntax to be very useful. Having something similar in Rust would be very nice to have.
As initially suggested in #2830, the proposal is to allow explicitly inferring types for enum variants by using a _::
prefix.
Examples
enum CompassPoint {
North,
South,
East,
West
}
let mut direction = CompassPoint::West;
direction = _::East;
match point {
_::East => { ... }
_::West => { ... }
_ => { ... }
}
fn function(cp: CompassPoint) {}
let direction = _::West;
function(direction);
Metadata
Metadata
Assignees
Labels
No labels