Even though they mention just one pointer in the text, I think they actually are saying the same than you, because the iterator is represented as a Range in the drawings that they include and shows both begin and end.
I think that's the best level of understanding for you, at this point. It's not an actual truth, but the closest approximation of truth that someone without years of experience programming in other languages would have.
The issue with that question is that it's, again, question directed toward someone with years of experience in C++, who suffered a lot from similar issues in C++ equivalent code and may appreciate what Rust does for them.
But to understand why this code shouldn't be allowed one have to know about intimate details of how iter is implemented, about how remove and shrink_to_fit are implemented and so on. If you know C++ (or even C) you would know the answers, if you come without such baggage then the whole question just becomes a riddle wrapped in a mystery inside an enigma.
Yes! A Vec contains a pointer plus to usize fields: length and capacity. If the pointer changes due to reallocation, the code I posted accesses the new pointer via the Vec structure. But using an iterator will continue to access the old (deallocated) pointer.
It's a great diagram, but note many of the exact details are implementation details; e.g. Mutex<T> is no longer boxed on most (but not all) platforms. Aside from field order, the Vec<_> and &[_] parts are guaranteed, though.[1]
The Vec<_> pointer might not point to the heap in the case of zero sized types or zero capacity. âŠī¸