rfcs
rfcs copied to clipboard
Converging let else
Rust has:
let PATTERN: TYPE = EXPRESSION else DIVERGING_BLOCK;
but it should allow:
let PATTERN: TYPE = EXPRESSION else CONVERGING_BLOCK;
if PATTERN
contains a single named variable. e.g.
let Foo(_, Some(Point2d(x, x))) | Bar(x) = foo() else {
3
};
do_something(x);
=>
let x = match foo() {
Foo(_, Some(Point2d(x, x))) | Bar(x) => x,
_ => 3,
};
do_something(x);