]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/option_map_or_none.txt
Rollup merge of #101389 - lukaslueg:rcgetmutdocs, r=m-ou-se
[rust.git] / src / tools / clippy / src / docs / option_map_or_none.txt
1 ### What it does
2 Checks for usage of `_.map_or(None, _)`.
3
4 ### Why is this bad?
5 Readability, this can be written more concisely as
6 `_.and_then(_)`.
7
8 ### Known problems
9 The order of the arguments is not in execution order.
10
11 ### Example
12 ```
13 opt.map_or(None, |a| Some(a + 1));
14 ```
15
16 Use instead:
17 ```
18 opt.and_then(|a| Some(a + 1));
19 ```