blob: 49c45d4ee5e9ce753c4085c5505434a92a8240e7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
### What it does
Checks for unnested or-patterns, e.g., `Some(0) | Some(2)` and
suggests replacing the pattern with a nested one, `Some(0 | 2)`.
Another way to think of this is that it rewrites patterns in
*disjunctive normal form (DNF)* into *conjunctive normal form (CNF)*.
### Why is this bad?
In the example above, `Some` is repeated, which unnecessarily complicates the pattern.
### Example
```
fn main() {
if let Some(0) | Some(2) = Some(0) {}
}
```
Use instead:
```
fn main() {
if let Some(0 | 2) = Some(0) {}
}
```
|