Skip to content

Commit 376eee7

Browse files
authored
Merge pull request #217 from ChaiTRex/master
Imported new documentation for .or_insert_with_key
2 parents 132995a + a0cec8b commit 376eee7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/map.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,9 +2595,12 @@ impl<'a, K, V, S, A: Allocator + Clone> Entry<'a, K, V, S, A> {
25952595
}
25962596
}
25972597

2598-
/// Ensures a value is in the entry by inserting, if empty, the result of the default function,
2599-
/// which takes the key as its argument, and returns a mutable reference to the value in the
2600-
/// entry.
2598+
/// Ensures a value is in the entry by inserting, if empty, the result of the default function.
2599+
/// This method allows for generating key-derived values for insertion by providing the default
2600+
/// function a reference to the key that was moved during the `.entry(key)` method call.
2601+
///
2602+
/// The reference to the moved key is provided so that cloning or copying the key is
2603+
/// unnecessary, unlike with `.or_insert_with(|| ... )`.
26012604
///
26022605
/// # Examples
26032606
///

0 commit comments

Comments
 (0)