"Convert `match` to let-else" assist
(let-else will be stable in about 6 weeks from now (Rust 1.65); we should probably not ship this assist before then)
It would be nice to have an assist to rewrite let statements with a match like the following, to their corresponding let-else form:
let val = match opt {
Some(it) => it,
None => return,
};
->
let Some(val) = opt else { return };
Criteria for the assist should be:
letstatement whose initializer is amatchexpressionmatchhas 2 arms, the first extracts data, the second has a diverging expression
We should also adjust existing “convert to early return” assist to use the new syntax
match has 2 arms, the first extracts data, the second has a diverging expression
Probably should handle:
let val = match opt {
None => return,
Some(it) => it,
};
As well.
https://user-images.githubusercontent.com/308347/200244795-545f0465-ec0f-4d8c-8f70-5f08aea99bf0.mp4
Ah, I just noticed this issue. It's a duplicate / subset? of #11908.