blob: 29a447af09b86f49aa81052bc32a52f5516d9367 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
### What it does
Checks for matches with two arms where an `if let else` will
usually suffice.
### Why is this bad?
Just readability – `if let` nests less than a `match`.
### Known problems
Personal style preferences may differ.
### Example
Using `match`:
```
match x {
Some(ref foo) => bar(foo),
_ => bar(&other_ref),
}
```
Using `if let` with `else`:
```
if let Some(ref foo) = x {
bar(foo);
} else {
bar(&other_ref);
}
```
|