Open
Description
What it does
Finds places where find_map
and filter_map
are used, where find
or filter
would suffice. These are those with a closure argument |a| ...
where a
is not mutated and the only possible return values are None
or Some(a)
.
Advantage
It's simpler.
Drawbacks
Determining the possible return values might be tricky, as might be determining whether a
is mutated.
Example
.find_map(|(i, j)| {
let [ri, rj] = regions.get_disjoint_mut([i, j]).unwrap();
ri.join(rj).then_some((i, j))
})
Could be written as:
.find(|(i, j)| {
let [ri, rj] = regions.get_disjoint_mut([i, j]).unwrap();
ri.join(rj)
})