Closed
Description
#![feature(plugin)]
#![plugin(clippy)]
fn main(){
let mut i = 0;
for _ in 1..10 {
i += 1;
}
println!("{}", i);
}
results in
src/lib.rs:9:5: 11:6 warning: the variable `i` is used as a loop counter. Consider using `for (i, item) in 1..10.enumerate()` or similar iterators, #[warn(explicit_counter_loop)] on by default
src/lib.rs: 9 for _ in 1..10 {
src/lib.rs:10 i += 1;
src/lib.rs:11 }
src/lib.rs:9:5: 11:6 note: in this expansion of for loop expansion
src/lib.rs:9:5: 11:6 help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#explicit_counter_loop
From what I understand, it is not possible to replicate the behavior of my program using enumerate
, so it shouldn't be suggested if the loop counter value is used outside the loop body