Closed
Description
What it does
Once the new let-else syntax is introduced, it would be awesome to have a lint which detects match and if-let statements which could be improved with let-else.
Categories (optional)
- Kind: clippy::style
What is the advantage of the recommended code over the original code
It's more concise and idiomatic.
Drawbacks
None.
Example
let foo = match expr1 {
Some(foo) => foo,
None => {
// error handling code
return;
}
};
let bar = if let Some(bar) = expr2 {
bar
} else {
// error handling code
return;
};
Could be written as:
let Some(foo) = expr1 else {
// error handling code
return;
};
let Some(bar) = expr2 else {
// error handling code
return;
};