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
The use is hidden in the signature of fn iter(&self) -> Iter<T>. We could change it to fn iter<'s>(&self) -> Iter<'s, T> and everything will go wrong as now iterator won't borrow linked list and could be iterated after list's destruction.
I guess this is why we need lifetimes but it is not explained in the section.
The text was updated successfully, but these errors were encountered:
https://rust-unofficial.github.io/too-many-lists/sixth-combinatorics.html
Here you implement
Iter
for the linked list assuming it will work, and it works. Good!But the reader might wonder what is the role of the lifetime
'a
? Indeed, we do not see any explicit uses of it exceptPhantomData
.The use is hidden in the signature of
fn iter(&self) -> Iter<T>
. We could change it tofn iter<'s>(&self) -> Iter<'s, T>
and everything will go wrong as now iterator won't borrow linked list and could be iterated after list's destruction.I guess this is why we need lifetimes but it is not explained in the section.
The text was updated successfully, but these errors were encountered: