>if the vector is marked as immutable
So, mark it as const here and see the same effect?
So, mark it as const here and see the same effect?
So, if you have a const reference, you can't make this mistake in it's entirety, but you can certainly make the mistake of keeping a reference to something you got through a const pointer.
Also, marking as const is something you have to opt-in to, and there is still disagreement on the value of const.
That is the point of C++, things other languages do at a language level you can easily design as a library without paying a cost if you do not use it.
You do not pay a performance cost for borrowing semantics in rust.
Which is precisely what Rust does.
c++ will let you push_back while holding a reference to an element of that vector. rust will not.