this post was submitted on 22 Oct 2023
18 points (95.0% liked)
Rust
5930 readers
33 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
This seems a bit misleading, noting that unique/mutable references aren't
Copy
. Shared references areCopy
because it's sound to have that, and it's a huge QOL improvement over the alternative.In this context mutability is part of the type signatures. &T and &mut T are two different types, the former implements copy but not the later. It's not really an "exception" in the type system.
I wouldn't say it's misleading. The question was specifically about shared references, it seemed obvious to me that's what they were referring to in their answer.
Sure, but the way I read the answer was "All primitive values on the stack are Copy", which isn't true (my example being mutable references, which have the same representation as shared ones, "just" a different semantic meaning). That's what I meant by misleading.