Skip to content

Commit a0cec8b

Browse files
committed
Imported new documentation for .or_insert_with_key
HashMap and BTreeMap in std have better documentation now for the entry.or_insert_with_key(...) method. This copies the documentation to hashbrown.
1 parent b226638 commit a0cec8b

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
@@ -2556,9 +2556,12 @@ impl<'a, K, V, S, A: AllocRef + Clone> Entry<'a, K, V, S, A> {
25562556
}
25572557
}
25582558

2559-
/// Ensures a value is in the entry by inserting, if empty, the result of the default function,
2560-
/// which takes the key as its argument, and returns a mutable reference to the value in the
2561-
/// entry.
2559+
/// Ensures a value is in the entry by inserting, if empty, the result of the default function.
2560+
/// This method allows for generating key-derived values for insertion by providing the default
2561+
/// function a reference to the key that was moved during the `.entry(key)` method call.
2562+
///
2563+
/// The reference to the moved key is provided so that cloning or copying the key is
2564+
/// unnecessary, unlike with `.or_insert_with(|| ... )`.
25622565
///
25632566
/// # Examples
25642567
///

0 commit comments

Comments
 (0)