Closed
Description
What it does
Finds occurrences of find_map
that could be simplified to find
.
Lint Name
simplifiable_find_map(?)
Category
complexity
Advantage
Essentially the same benefits of the filter_next
lint (in fact, this could perhaps be an enhancement of that lint).
Drawbacks
None(?).
Example
pub fn main() {
let xs = [0, 1, 2];
let odd = xs.iter().find_map(|x| if x % 2 == 1 { Some(x) } else { None });
println!("{:?}", odd);
}
Could be written as:
pub fn main() {
let xs = [0, 1, 2];
let odd = xs.iter().find(|x| *x % 2 == 1);
println!("{:?}", odd);
}
A tricky part could be that find
's function argument expects a reference, but find
's does not.