summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/match_result_ok.txt
blob: eea7c8e00f1bb6b7bd0f3d7ccfe8bce8f0228914 (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
### What it does
Checks for unnecessary `ok()` in `while let`.

### Why is this bad?
Calling `ok()` in `while let` is unnecessary, instead match
on `Ok(pat)`

### Example
```
while let Some(value) = iter.next().ok() {
    vec.push(value)
}

if let Some(value) = iter.next().ok() {
    vec.push(value)
}
```
Use instead:
```
while let Ok(value) = iter.next() {
    vec.push(value)
}

if let Ok(value) = iter.next() {
       vec.push(value)
}
```