logoalt Hacker News

matjayesterday at 9:04 PM0 repliesview on HN

.len doesn't work on a list (because it might mislead you about the efficiency of the operation if it did exist), so it's better to use iterators - so then you can change the underlying type without changing your code.

But then, saying while "let Some(item) = iter.next()" everytime is tedious, so they give you .iter() - for any type that is efficiently iterable.

Nothing stopping you using a manual loop that you need to update if you change the container type.