summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/single_match.txt
blob: 31dde4da8489cece5111dfcf9d01a8d7df48854d (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 matches with a single arm where an `if let`
will usually suffice.

### Why is this bad?
Just readability – `if let` nests less than a `match`.

### Example
```
match x {
    Some(ref foo) => bar(foo),
    _ => (),
}
```

Use instead:
```
if let Some(ref foo) = x {
    bar(foo);
}
```