1 #![warn(clippy::explicit_counter_loop)]
4 let mut vec = vec![1, 2, 3, 4];
29 // should not trigger the lint because variable is used after the loop #473
30 let vec = vec![1, 2, 3];
35 println!("index: {}", index);
37 // should not trigger the lint because the count is conditional #1219
40 for ch in text.chars() {
41 println!("{}", count);
48 // should not trigger the lint because the count is conditional
51 for ch in text.chars() {
52 println!("{}", count);
58 // should trigger the lint because the count is not conditional
61 for ch in text.chars() {
62 println!("{}", count);
69 // should trigger the lint because the count is not conditional
72 for ch in text.chars() {
73 println!("{}", count);
80 // should not trigger the lint because the count is incremented multiple times
83 for ch in text.chars() {
84 println!("{}", count);
95 // should not trigger the lint because the count is incremented multiple times
97 let erasures = vec![];
99 println!("{}", skips);
100 while erasures.contains(&(i + skips)) {
105 // should not trigger the lint because the count is incremented multiple times
108 println!("{}", skips);
116 // should not trigger the lint because the count is incremented multiple times
119 println!("{}", skips);
138 let slice = &[1, 2, 3];
141 // should not trigger the lint because the count is used after the loop
145 let _closure = || println!("index: {}", index);
151 let slice = &[1, 2, 3];
153 // should not trigger the lint because the count is used after incremented
157 println!("{}", count);
164 let slice = &[1, 2, 3];
166 let index_usize: usize = 0;
167 let mut idx_usize: usize = 0;
169 // should suggest `enumerate`
171 if idx_usize == index_usize {
178 let index_u32: u32 = 0;
179 let mut idx_u32: u32 = 0;
181 // should suggest `zip`
183 if idx_u32 == index_u32 {