-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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);
shepmaster, Fishrock123, chrisdickinson, SadiinsoSnowfall, iago-lito and 44 morepetrochenkov, lebensterben, ods, 8573, konsumlamm and 1 morekennytmnanoqsh, SadiinsoSnowfall, ceejbot, iago-lito, cottonguard and 14 moreigotfrigotfr
Metadata
Metadata
Assignees
Labels
No labels