Earlier quoted context omitted.
Arc vs Rc compared to shared_ptr was what I was going to say for overhead, as well as things like the lack of move constructors, which (should) make Vec faster than std::vec. For stronger guarantees, I was going to point out that if you std::move a uniq_ptr, it becomes null, but Rust prevents using a Box that's been moved at compile time. Your example is good here too.
> the lack of move constructors, which (should) make Vec faster than std::vec. So you are saying that the lack of move constructors (hence copying the structure) will make Vec faster than std::vector? I don't follow that logic, wouldn't it actually be slower? > I was going to point out that if you std::move a uniq_ptr, it becomes null The original becames null because the semantic is actually tranfering ownership whi…
> I don't follow that logic,
Specifically, I mean that when the vector changes size, the vector needs to reallocate. In Rust, since there are no move constructors, it's just a memcpy of the whole chunk of memory, one big one. Very straightforward and fast. In C++, you need to call all those move constructors. > The original becames null because the semantic is actually tranfering ownership
Absolutely. In Rust, this is tracked at compile time, and attempting to use after the move is a compile-time error. In C++, you'll get a null pointer dereference. (I _think_ that technically it's in an 'unspecified' state, not a null one, but on my system, null is what I get).