You should write your program as if all moves act as destructive bitwise copies. However, this is not always what happens, various optimizations can change this behaviour when there's no need to actually copy. For example:
fn bar() -> [u8, 1024] {
let x = [1; 1024];
x
}
fn foo() {
let x = bar();
println!("{}", x);
}
In this example, (conceptually) x
in the function bar()
is moved into x
in the function foo()
when bar()
returns.
But in reality, if the function is inlined, no move happens at all. If you're curious about what is happening, check out godbolt.org to view the emitted assembly.
Also, as always, if your concern is a performance reason, give it a try first and benchmark, you might be surprised by some of the optimizations rustc/LLVM are able to perform.