mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-15 12:39:31 +03:00
Improved documentation for HashMap/BTreeMap Entry's .or_insert_with_key method
This commit is contained in:
@@ -116,9 +116,12 @@ pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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.<br />
|
||||
///
|
||||
/// The reference to the moved key is provided so that cloning or copying the key is
|
||||
/// unnecessary, unlike with `.or_insert_with(|| ... )`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
||||
@@ -2222,9 +2222,12 @@ pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
|
||||
}
|
||||
}
|
||||
|
||||
/// 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
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user