We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c5f3f9d commit 949b125Copy full SHA for 949b125
tests/ui/for_loops_over_options.rs
@@ -0,0 +1,31 @@
1
+#![warn(clippy::for_loops_over_options)]
2
+
3
+fn main() {
4
+ let x = vec![Some(1), Some(2), Some(3)];
5
+ for n in x {
6
+ if let Some(n) = n {
7
+ println!("{}", n);
8
+ }
9
10
11
+ let y: Vec<Result<i32, i32>> = vec![];
12
+ for n in y.clone() {
13
+ if let Ok(n) = n {
14
15
16
17
18
+ // This should not trigger the lint
19
20
21
22
+ } else {
23
+ println!("Oops!");
24
25
26
27
28
+ for n in vec![Some(1), Some(2), Some(3)].iter().flatten() {
29
30
31
+}
0 commit comments