summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/manual_filter.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/manual_filter.txt')
-rw-r--r--src/tools/clippy/src/docs/manual_filter.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/manual_filter.txt b/src/tools/clippy/src/docs/manual_filter.txt
new file mode 100644
index 000000000..19a4d9319
--- /dev/null
+++ b/src/tools/clippy/src/docs/manual_filter.txt
@@ -0,0 +1,21 @@
+### What it does
+Checks for usages of `match` which could be implemented using `filter`
+
+### Why is this bad?
+Using the `filter` method is clearer and more concise.
+
+### Example
+```
+match Some(0) {
+ Some(x) => if x % 2 == 0 {
+ Some(x)
+ } else {
+ None
+ },
+ None => None,
+};
+```
+Use instead:
+```
+Some(0).filter(|&x| x % 2 == 0);
+``` \ No newline at end of file