]> git.lizzy.rs Git - rust.git/blob - src/docs/match_result_ok.txt
Auto merge of #9421 - xphoniex:fix-#9420, r=giraffate
[rust.git] / src / docs / match_result_ok.txt
1 ### What it does
2 Checks for unnecessary `ok()` in `while let`.
3
4 ### Why is this bad?
5 Calling `ok()` in `while let` is unnecessary, instead match
6 on `Ok(pat)`
7
8 ### Example
9 ```
10 while let Some(value) = iter.next().ok() {
11     vec.push(value)
12 }
13
14 if let Some(value) = iter.next().ok() {
15     vec.push(value)
16 }
17 ```
18 Use instead:
19 ```
20 while let Ok(value) = iter.next() {
21     vec.push(value)
22 }
23
24 if let Ok(value) = iter.next() {
25        vec.push(value)
26 }
27 ```