Hacker News new | ask | show | jobs
by hetman 3875 days 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).
1 comments

Ok, 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.