You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sadly, Rust has nothing like a yield statement (yet), so we're going to have to implement the logic ourselves. Also, there's actually 3 different kinds of iterator each collection should endeavour to implement:
IntoIter - T
IterMut - &mut T
Iter - &T
We actually already have all the tools to implement IntoIter using List's interface: just call pop over and over. As such, we'll just implement IntoIter as a newtype wrapper around List
I think could do with a bit more ramp up into why you use a newtype wrapper. I'm not sure what the best way to approach it is, but maybe the following questions/comments could help:
Mention that we could just use self.pop(), but that the other iterator types will need to keep track of where they got to in the list.
What is a newtype struct?
When do we use a newtype struct?
Maybe gloss over the traits on foreign types stuff...
The text was updated successfully, but these errors were encountered:
Thanks for the excellent tutorial.
I think could do with a bit more ramp up into why you use a newtype wrapper. I'm not sure what the best way to approach it is, but maybe the following questions/comments could help:
self.pop()
, but that the other iterator types will need to keep track of where they got to in the list.The text was updated successfully, but these errors were encountered: