3 ms·
There is an important distinction in Rust: ownership. Copyable objects are (by definition) simple enough that copying them does not introduce aliasing. Objects
by wycats 12y ago
There is an important distinction in Rust: ownership.
Copyable objects are (by definition) simple enough that copying them does not introduce aliasing. Objects with heap pointers or destructors cannot be copied, because now there would be two "owners" of those values.
For what it's worth, I've found that a lot of these assumptions ("it doesn't matter, let the compile optimize it") really remove the programmer from important power.
And before you find yourself saying "are you saying everyone should write everything in assembler?":
1. There is a distinction between writing code in assembler and having to use a `&` sigil for "by-reference" in a language that has lambdas, traits and many other high-level features.
2. You should generally use Rust for cases where performance characteristics are important, and where control over memory is important. If you're sure it's not important, by all means go with a higher-level language that abstracts it away.
I made this point (perhaps more clearly) in my talk at GoGaRuCo: http://www.youtube.com/watch?v=ySW6Yk_DerY http://www.youtube.com/watch?v=ySW6Yk_DerY