|
|
|
|
|
by likeliv
2438 days ago
|
|
It is perfect fine to take by value something that is not Copy to transfer its ownership. It is a compiler error to use the value after it was moved. And the compiler error is quite explicit about how to solve it For example you can explicitly clone let y = add(x.clone());
let z = add(x);
|
|
What the chance in real life that a function like that cannot simply use a reference?
In my learning Rust, my life became significantly better and easier when I started to references to borrow as much as possible.