1 #![warn(clippy::for_loops_over_fallibles)]
2 #![allow(clippy::uninlined_format_args)]
4 fn for_loops_over_fallibles() {
6 let mut result = option.ok_or("x not found");
9 // check over an `Option`
14 // check over an `Option`
15 for x in option.iter() {
19 // check over a `Result`
24 // check over a `Result`
25 for x in result.iter_mut() {
29 // check over a `Result`
30 for x in result.into_iter() {
34 for x in option.ok_or("x not found") {
38 // make sure LOOP_OVER_NEXT lint takes clippy::precedence when next() is the last call
40 for x in v.iter().next() {
44 // make sure we lint when next() is not the last call in the chain
45 for x in v.iter().next().and(Some(0)) {
49 for x in v.iter().next().ok_or("x not found") {
53 // check for false positives
55 // for loop false positive
60 // while let false positive for Option
61 while let Some(x) = option {
66 // while let false positive for Result
67 while let Ok(x) = result {