summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/manual_filter.txt
blob: 19a4d9319d94b700d1e88671e4e8f9f6ae6c20ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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);
```