comprehensive-rust
comprehensive-rust copied to clipboard
Uses into_inter consistently in day 1
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
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.
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 returnedIterator
hasItem=&i8
instead ofItem=i8
, intended as a segue intoIntoIterator
.
Yes, that was the idea! :smile:
We could add a note about this somewhere if you like?
I'll close this since the idea was to let people play with iter()
and into_iter()
on their own to notice the differences.