Skip to content

Commit 2fe1cf0

Browse files
committed
Update 0060-collection-views.md
Make OccupiedEntry.set take &mut self.
1 parent 6ec1aa0 commit 2fe1cf0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

active/0060-collection-views.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl<'a, K, V> OccupiedEntry<'a, K, V> {
9999
pub fn into_mut(self) -> &'a mut V;
100100
101101
/// Sets the value stored in this Entry
102-
pub fn set(self, value: V) -> V;
102+
pub fn set(&mut self, value: V) -> V;
103103
104104
/// Takes the value stored in this Entry
105105
pub fn take(self) -> V;
@@ -130,8 +130,8 @@ the guarantor, and destroy the Entry. This is to avoid the costs of maintaining
130130
otherwise isn't particularly interesting anymore.
131131

132132
If there is a match, a more robust set of options is provided. `get` and `get_mut` provide access to the
133-
value found in the location. `set` behaves as the vacant variant, but also yields the old value. `take`
134-
simply removes the found value, and destroys the entry for similar reasons as `set`.
133+
value found in the location. `set` behaves as the vacant variant, but without destroying the entry.
134+
It also yields the old value. `take` simply removes the found value, and destroys the entry for similar reasons as `set`.
135135

136136
Let's look at how we one now writes `insert_or_update`:
137137

0 commit comments

Comments
 (0)