Open
Description
What it does
Improve the code to be more concise
Advantage
- Less and cleaner
Drawbacks
No response
Example
fn foo() {
let x = Some("foo".to_owned());
let _y = x.and_then(|v| v.starts_with('f')
.then_some(v));
}
Could be written as:
fn foo() {
let x = Some("foo".to_owned());
let _y = x.filter(|v| v.starts_with('f'));
}