1 #![warn(clippy::explicit_counter_loop)]
2 #![allow(clippy::uninlined_format_args)]
5 let mut vec = vec![1, 2, 3, 4];
30 // should not trigger the lint because variable is used after the loop #473
31 let vec = vec![1, 2, 3];
36 println!("index: {}", index);
38 // should not trigger the lint because the count is conditional #1219
41 for ch in text.chars() {
42 println!("{}", count);
49 // should not trigger the lint because the count is conditional
52 for ch in text.chars() {
53 println!("{}", count);
59 // should trigger the lint because the count is not conditional
62 for ch in text.chars() {
63 println!("{}", count);
70 // should trigger the lint because the count is not conditional
73 for ch in text.chars() {
74 println!("{}", count);
81 // should not trigger the lint because the count is incremented multiple times
84 for ch in text.chars() {
85 println!("{}", count);
96 // should not trigger the lint because the count is incremented multiple times
98 let erasures = vec![];
100 println!("{}", skips);
101 while erasures.contains(&(i + skips)) {
106 // should not trigger the lint because the count is incremented multiple times
109 println!("{}", skips);
117 // should not trigger the lint because the count is incremented multiple times
120 println!("{}", skips);
139 let slice = &[1, 2, 3];
142 // should not trigger the lint because the count is used after the loop
146 let _closure = || println!("index: {}", index);
152 let slice = &[1, 2, 3];
154 // should not trigger the lint because the count is used after incremented
158 println!("{}", count);
165 let slice = &[1, 2, 3];
167 let index_usize: usize = 0;
168 let mut idx_usize: usize = 0;
170 // should suggest `enumerate`
172 if idx_usize == index_usize {
179 let index_u32: u32 = 0;
180 let mut idx_u32: u32 = 0;
182 // should suggest `zip`
184 if idx_u32 == index_u32 {