From a0cec8be8e3be2766ec3e477522b39c11723ac55 Mon Sep 17 00:00:00 2001 From: "Chai T. Rex" Date: Mon, 7 Dec 2020 21:44:07 -0500 Subject: [PATCH] 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. --- src/map.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/map.rs b/src/map.rs index 1217945a34..8ef2977c3a 100644 --- a/src/map.rs +++ b/src/map.rs @@ -2556,9 +2556,12 @@ impl<'a, K, V, S, A: AllocRef + Clone> Entry<'a, K, V, S, A> { } } - /// Ensures a value is in the entry by inserting, if empty, the result of the default function, - /// which takes the key as its argument, and returns a mutable reference to the value in the - /// entry. + /// Ensures a value is in the entry by inserting, if empty, the result of the default function. + /// This method allows for generating key-derived values for insertion by providing the default + /// function a reference to the key that was moved during the `.entry(key)` method call. + /// + /// The reference to the moved key is provided so that cloning or copying the key is + /// unnecessary, unlike with `.or_insert_with(|| ... )`. /// /// # Examples ///