]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/option_filter_map.txt
Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup
[rust.git] / src / tools / clippy / src / docs / option_filter_map.txt
1 ### What it does
2 Checks for indirect collection of populated `Option`
3
4 ### Why is this bad?
5 `Option` is like a collection of 0-1 things, so `flatten`
6 automatically does this without suspicious-looking `unwrap` calls.
7
8 ### Example
9 ```
10 let _ = std::iter::empty::<Option<i32>>().filter(Option::is_some).map(Option::unwrap);
11 ```
12 Use instead:
13 ```
14 let _ = std::iter::empty::<Option<i32>>().flatten();
15 ```