Rollup merge of #113153 - tshepang:patch-6, r=cuviper

make HashMap::or_insert_with example more simple
This commit is contained in:
Matthias Krüger 2023-07-01 00:35:05 +02:00 committed by GitHub
commit 709f184593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2543,12 +2543,12 @@ impl<'a, K, V> Entry<'a, K, V> {
/// ```
/// use std::collections::HashMap;
///
/// let mut map: HashMap<&str, String> = HashMap::new();
/// let s = "hoho".to_string();
/// let mut map = HashMap::new();
/// let value = "hoho";
///
/// map.entry("poneyland").or_insert_with(|| s);
/// map.entry("poneyland").or_insert_with(|| value);
///
/// assert_eq!(map["poneyland"], "hoho".to_string());
/// assert_eq!(map["poneyland"], "hoho");
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]