Using .skip(0)
on an iterator does nothing, which is likely to be a mistake. It is more probable that .skip(1)
was
intended to skip the first element, or if not, the .skip(0)
call should be removed to avoid confusion and make the code clearer.
Code examples
Noncompliant code example
let v = vec![1, 2, 3];
let x = v.iter().skip(0).collect::<Vec<_>>(); // Noncompliant: .skip(0) does nothing
Compliant solution
let v = vec![1, 2, 3];
let x = v.iter().collect::<Vec<_>>(); // Compliant: No .skip(0) call makes the intent clear