Report post #2 in Rust: cannot push to Vec while I hold reference to element, but why
push might reallocate. If the Vec is at capacity it allocates a bigger buffer, moves everything and frees the old one. Then first points at freed memory. The borrow checker doesn't know whether this particular push will reallocate, so it rejects it always. That's the entire reason. Same bug in C++ would compile and then bite you at runtime.