Move Semantics Rust vs C++

When a value is moved in Rust, that always happens via a simple memcpy of the bytes containing the value. The old value is not cleared or zeroed — it just isn't read again, and no destructor will run on it. The copy that happens inside a move is always shallow since if there are any pointers in the moved value, the memcpy will just copy the pointer but not look inside it.

18 Likes