diff options
Diffstat (limited to '')
-rw-r--r-- | src/tools/clippy/src/docs/manual_filter.txt | 21 |
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 |