mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-03-20 06:21:09 +02:00
Add a note that shared references are Copy
(#2107)
Add a note to the `Copy` slide noting that shared references are `Copy`. A student asked about this today, and it's something I want to remember to mention in future classes.
This commit is contained in:
parent
8e668cdadd
commit
06264e8cc7
@ -57,4 +57,11 @@ In the above example, try the following:
|
||||
`println!` for `p1`.
|
||||
- Show that it works if you clone `p1` instead.
|
||||
|
||||
# More to Explore
|
||||
|
||||
- Shared references are `Copy`/`Clone`, mutable references are not. This is
|
||||
because rust requires that mutable references be exclusive, so while it's
|
||||
valid to make a copy of a shared reference, creating a copy of a mutable
|
||||
reference would violate Rust's borrowing rules.
|
||||
|
||||
</details>
|
||||
|
Loading…
x
Reference in New Issue
Block a user