Pass-By-Move is the default in Rust. Pass by move makes no damn sense for a simple struct of {X, Y, Z} coordinates. [..] Seems sus to make it the default
Well, for one, pass-by-reference requires a deference. Pass-by-move also matches the ownership model in Rust.
Just because Rust uses that ownership model does not mean it will actually use std::move for every function call. Rust's compiler is able to make assumptions based on the fact that things are generally immutable and copied rather than aliased that can eliminate most actual moves or copies unless it cannot prove that the function doesn't modify the value
Pass by Copy is the alternative and is the sensible default for simple stack based structs.
For purely stack based data types, Pass by Move is Pass by Copy with the gotcha of invalidating the original variable. Of immutability is the goal, Pass by Move is far worse than Copy for simple stack structs.
View all comments
Show parent comment
1
u/WriterPlastic9350 Oct 10 '26
Well, for one, pass-by-reference requires a deference. Pass-by-move also matches the ownership model in Rust.
Just because Rust uses that ownership model does not mean it will actually use
std::movefor every function call. Rust's compiler is able to make assumptions based on the fact that things are generally immutable and copied rather than aliased that can eliminate most actual moves or copies unless it cannot prove that the function doesn't modify the value