diff options
Diffstat (limited to 'src/tools/clippy/src/docs/option_map_or_none.txt')
-rw-r--r-- | src/tools/clippy/src/docs/option_map_or_none.txt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/option_map_or_none.txt b/src/tools/clippy/src/docs/option_map_or_none.txt new file mode 100644 index 000000000..c86c65215 --- /dev/null +++ b/src/tools/clippy/src/docs/option_map_or_none.txt @@ -0,0 +1,19 @@ +### What it does +Checks for usage of `_.map_or(None, _)`. + +### Why is this bad? +Readability, this can be written more concisely as +`_.and_then(_)`. + +### Known problems +The order of the arguments is not in execution order. + +### Example +``` +opt.map_or(None, |a| Some(a + 1)); +``` + +Use instead: +``` +opt.and_then(|a| Some(a + 1)); +```
\ No newline at end of file |