1 #![warn(clippy::manual_flatten)]
2 #![allow(clippy::useless_vec)]
5 // Test for loop over implicitly adjusted `Iterator` with `if let` expression
6 let x = vec![Some(1), Some(2), Some(3)];
13 // Test for loop over implicitly implicitly adjusted `Iterator` with `if let` statement
14 let y: Vec<Result<i32, i32>> = vec![];
21 // Test for loop over by reference
28 // Test for loop over an implicit reference
29 // Note: if `clippy::manual_flatten` is made autofixable, this case will
30 // lead to a follow-up lint `clippy::into_iter_on_ref`
38 // Test for loop over `Iterator` with `if let` expression
39 let z = vec![Some(1), Some(2), Some(3)];
47 // Using the `None` variant should not trigger the lint
48 // Note: for an autofixable suggestion, the binding in the for loop has to take the
49 // name of the binding in the `if let`
50 let z = vec![Some(1), Some(2), Some(3)];
57 // Using the `Err` variant should not trigger the lint
60 println!("Oops: {}!", e);
64 // Having an else clause should not trigger the lint
73 let vec_of_ref = vec![&Some(1)];
74 for n in &vec_of_ref {
80 let vec_of_ref = &vec_of_ref;
87 let slice_of_ref = &[&Some(1)];
88 for n in slice_of_ref {
94 // Using manual flatten should not trigger the lint
95 for n in vec![Some(1), Some(2), Some(3)].iter().flatten() {