comprehensive-rust icon indicating copy to clipboard operation
comprehensive-rust copied to clipboard

Uses into_inter consistently in day 1

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

This page started by using iter and then used into_iter. No explanation was given. Worse, since the second part is about IntoIterator, intuition would indicate that the word "into" in IntoIterator and in into_iter refers to the same concept, and this is why into was not necessary in the first part of the page.

Since the authors seems not to want to introduce the difference between into_iter and iter here, I believe it’s more sensical to use into_iter everywhere

Arthur-Milchior avatar Dec 22 '22 01:12 Arthur-Milchior

My understanding is that this chapter is intended to introduce the difference between .iter() and .into_iter(), thus "What is the type returned by the iterator? Test your answer here:" and " Why is this type used?", referring to the fact that the returned Iterator has Item=&i8 instead of Item=i8, intended as a segue into IntoIterator.

If you would prefer to make that more explicit, rather than depending on the speaker as these notes originally were, I think that could be helpful.

maurer avatar Dec 26 '22 17:12 maurer

My understanding is that this chapter is intended to introduce the difference between .iter() and .into_iter(), thus "What is the type returned by the iterator? Test your answer here:" and " Why is this type used?", referring to the fact that the returned Iterator has Item=&i8 instead of Item=i8, intended as a segue into IntoIterator.

Yes, that was the idea! :smile:

We could add a note about this somewhere if you like?

mgeisler avatar Jan 05 '23 14:01 mgeisler

I'll close this since the idea was to let people play with iter() and into_iter() on their own to notice the differences.

mgeisler avatar Jan 11 '23 07:01 mgeisler