1 #![warn(clippy::for_loops_over_fallibles)]
3 fn for_loops_over_fallibles() {
5 let mut result = option.ok_or("x not found");
8 // check over an `Option`
13 // check over an `Option`
14 for x in option.iter() {
18 // check over a `Result`
23 // check over a `Result`
24 for x in result.iter_mut() {
28 // check over a `Result`
29 for x in result.into_iter() {
33 for x in option.ok_or("x not found") {
37 // make sure LOOP_OVER_NEXT lint takes clippy::precedence when next() is the last call
39 for x in v.iter().next() {
43 // make sure we lint when next() is not the last call in the chain
44 for x in v.iter().next().and(Some(0)) {
48 for x in v.iter().next().ok_or("x not found") {
52 // check for false positives
54 // for loop false positive
59 // while let false positive for Option
60 while let Some(x) = option {
65 // while let false positive for Result
66 while let Ok(x) = result {