Open
Description
What it does
Improve implicit return lint. It wood be more classic-like style to omit the return
keyword on visually inlined closures. Like Java and JS do with lambdas.
Categories (optional)
- style
What is the advantage of the recommended code over the original code
- Seems more classic-like as Java's and JS' lambdas.
Drawbacks
None.
Example
fn foo_1(bar: Bar) -> Baz {
return bar.map(|b| return b.baz.clone()); // needless closure return
}
fn foo_2(bar: Bar) -> Baz {
return bar.map(|b| {
b.baz.clone() // missing return, since we use curly brackets
});
}
Could be written as:
fn foo_1(bar: Bar) -> Baz {
return bar.map(|b| b.baz.clone());
}
fn foo_2(bar: Bar) -> Baz {
return bar.map(|b| {
return b.baz.clone();
});
}