too-many-lists icon indicating copy to clipboard operation
too-many-lists copied to clipboard

Mention iterating twice in second implementation

Open Arthur-Milchior opened this issue 2 years ago • 1 comments

If I were to implement tests for list in any most other languages, I consider that I would check that iteration don't change the list, that we can iterate twice on it. I suggest that it makes sense to add a small discussion about this topic, explaining why it can't be done with into_iter, the tradeoff between next giving ownership and keeping ownership of list.

Arthur-Milchior avatar May 18 '22 22:05 Arthur-Milchior

I'd also consider creating a variable out of the result of next and using it in the second iteration of the test. That would show that creating an iterator while holding a reference to the result of next is possible with iter but not with mut_iter.

However, I am less certain that it is relevant than this PR, so I'll wait until you give your opinion to potentially write it if you're interested

Arthur-Milchior avatar May 19 '22 00:05 Arthur-Milchior