News for hackers. Stuff that matters.
Re:You can't Rust that by masklinn on Sunday April 01, 2018 @07:27AM (#16727748)
> I've had a hard time understanding whether I'm telling the compiler to move or copy. In other words I need to understand better what I'm telling it to do

You're not telling it anything, in Rust copy v move is a type-level concern: either the type is "move" (the default) or it's "copy".

There is no difference at the machine-level either (it's semantically doing a memcpy either way, Rust has no move ctor v copy ctor and its move semantics are somewhat different than C++), the difference is whether the compiler will let you use the source object afterwards.

Incidentally, I believe you're not really "telling the compiler to move or copy" in C++ either, you're only suggesting that it can move and whether it actually does so depends on the type's ctors and IIRC the receiver's overloads: std::move on a type which can't be moved or with a target which doesn't care does not do anything.

There are no comments on this comment yet.