Moves in Function Calls
- With the first call to ,
main
gives up ownership ofname
. Afterwards,name
cannot be used anymore within . main
can retain ownership if it passes as a reference (&name
) and ifsay_hello
accepts a reference as a parameter.- Rust makes it harder than C++ to inadvertently create copies by making move semantics the default, and by forcing programmers to make clones explicit.