summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/manual_find_map.txt
blob: 83b22060c0e193a5510d103afdb7eb78f400b687 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
### What it does
Checks for usage of `_.find(_).map(_)` that can be written more simply
as `find_map(_)`.

### Why is this bad?
Redundant code in the `find` and `map` operations is poor style and
less performant.

### Example
```
(0_i32..10)
    .find(|n| n.checked_add(1).is_some())
    .map(|n| n.checked_add(1).unwrap());
```

Use instead:
```
(0_i32..10).find_map(|n| n.checked_add(1));
```