]>
Commit | Line | Data |
---|---|---|
f2b60f7d FG |
1 | ### What it does |
2 | Checks for usages of `Iterator::flat_map()` where `filter_map()` could be | |
3 | used instead. | |
4 | ||
5 | ### Why is this bad? | |
6 | When applicable, `filter_map()` is more clear since it shows that | |
7 | `Option` is used to produce 0 or 1 items. | |
8 | ||
9 | ### Example | |
10 | ``` | |
11 | let nums: Vec<i32> = ["1", "2", "whee!"].iter().flat_map(|x| x.parse().ok()).collect(); | |
12 | ``` | |
13 | Use instead: | |
14 | ``` | |
15 | let nums: Vec<i32> = ["1", "2", "whee!"].iter().filter_map(|x| x.parse().ok()).collect(); | |
16 | ``` |