4 ms·
No, Rust invokes the equivalent of a memcpy() when moving ownership for types with the Copy trait. A borrow is just like a pointer (and indeed you have to deref
by hetman 11y ago
No, Rust invokes the equivalent of a memcpy() when moving ownership for types with the Copy trait. A borrow is just like a pointer (and indeed you have to dereference it with a * to get access to the contents).
- markus2012 11y agoOk, just to summarize: foo(some_struct) == memcpy() for both copy and move. foo(&some_struct) == copy usize ref/pointer value onto stack So, mostly the same as C++. The exception is that Rust can use a ref under the hood for foo(some_struct) if it wants.