Vec: iter() start with index 1

  1. I need to iterate over a vector. Normally I would just do
for x in v.iter() {
...
}
  1. However, I want to start with the 2nd element (index 1), without constructing a subvector. How can I skip the first element?

for x in v.iter().skip(1) { ... }

or

for x in v[1..].iter() { ... }

5 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.