1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-20 22:36:03 +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:
Nicole L 2024-05-30 07:19:33 -07:00 committed by GitHub
parent 8e668cdadd
commit 06264e8cc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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>