summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/manual_find_map.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/manual_find_map.txt')
-rw-r--r--src/tools/clippy/src/docs/manual_find_map.txt19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/manual_find_map.txt b/src/tools/clippy/src/docs/manual_find_map.txt
new file mode 100644
index 000000000..83b22060c
--- /dev/null
+++ b/src/tools/clippy/src/docs/manual_find_map.txt
@@ -0,0 +1,19 @@
+### What it does
+Checks for usage of `_.find(_).map(_)` that can be written more simply
+as `find_map(_)`.
+
+### Why is this bad?
+Redundant code in the `find` and `map` operations is poor style and
+less performant.
+
+### Example
+```
+(0_i32..10)
+ .find(|n| n.checked_add(1).is_some())
+ .map(|n| n.checked_add(1).unwrap());
+```
+
+Use instead:
+```
+(0_i32..10).find_map(|n| n.checked_add(1));
+``` \ No newline at end of file