Skip to content

Commit 06264e8

Browse files
authored
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.
1 parent 8e668cd commit 06264e8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/memory-management/copy-types.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,11 @@ In the above example, try the following:
5757
`println!` for `p1`.
5858
- Show that it works if you clone `p1` instead.
5959

60+
# More to Explore
61+
62+
- Shared references are `Copy`/`Clone`, mutable references are not. This is
63+
because rust requires that mutable references be exclusive, so while it's
64+
valid to make a copy of a shared reference, creating a copy of a mutable
65+
reference would violate Rust's borrowing rules.
66+
6067
</details>

0 commit comments

Comments
 (0)