]> git.lizzy.rs Git - rust.git/blob - src/docs/filter_map_next.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / filter_map_next.txt
1 ### What it does
2 Checks for usage of `_.filter_map(_).next()`.
3
4 ### Why is this bad?
5 Readability, this can be written more concisely as
6 `_.find_map(_)`.
7
8 ### Example
9 ```
10  (0..3).filter_map(|x| if x == 2 { Some(x) } else { None }).next();
11 ```
12 Can be written as
13
14 ```
15  (0..3).find_map(|x| if x == 2 { Some(x) } else { None });
16 ```