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