(Sorry if there was a better category to post this under)
The following code compiles and runs without warning, whether or not we use let mut =
or = &mut
for the iterator creation:
fn main() {
let nums = vec![2, 4, 6, 8];
let mut num_iter = nums.iter();
// let num_iter = &mut nums.iter();
let n1 = num_iter.next();
println!("first num is {:?}", n1)
}
Since it seems to be that the former (let mut
) is a bit of a code smell when the latter (&mut
) would work in its stead, would it make sense to have a (possibly optional) lint for this case?