]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/manual_find_map.txt
Rollup merge of #101602 - nnethercote:AttrTokenStream, r=petrochenkov
[rust.git] / src / tools / clippy / src / docs / manual_find_map.txt
1 ### What it does
2 Checks for usage of `_.find(_).map(_)` that can be written more simply
3 as `find_map(_)`.
4
5 ### Why is this bad?
6 Redundant code in the `find` and `map` operations is poor style and
7 less performant.
8
9 ### Example
10 ```
11 (0_i32..10)
12     .find(|n| n.checked_add(1).is_some())
13     .map(|n| n.checked_add(1).unwrap());
14 ```
15
16 Use instead:
17 ```
18 (0_i32..10).find_map(|n| n.checked_add(1));
19 ```