News for hackers. Stuff that matters.
Re:Common Rust Lifetime Misconceptions by cesarb on Saturday May 23, 2020 @03:41PM (#23285751)
Yes, the optimizer (LLVM) can often optimize memcpy(), and this is not exclusive to Rust: the same optimizations happen with C and C++ (a well-known trick to avoid some undefined behaviors in C is to do a memcpy(), which the optimizer will then elide). It doesn't change that, before the optimization passes, it's doing the equivalent of a memcpy().

> memcpy sounds like what would happen in the case of a copy or clone, not a move.

In Rust, copy and move are nearly identical; the only difference is that, after a move, the compiler doesn't let you access the old value. Clone is different, since it can be overridden to do anything the programmer desires, but by default, it's identical to copy.

There are no comments on this comment yet.