Rollup merge of #113153 - tshepang:patch-6, r=cuviper
make HashMap::or_insert_with example more simple
This commit is contained in:
commit
709f184593
@ -2543,12 +2543,12 @@ impl<'a, K, V> Entry<'a, K, V> {
|
|||||||
/// ```
|
/// ```
|
||||||
/// use std::collections::HashMap;
|
/// use std::collections::HashMap;
|
||||||
///
|
///
|
||||||
/// let mut map: HashMap<&str, String> = HashMap::new();
|
/// let mut map = HashMap::new();
|
||||||
/// let s = "hoho".to_string();
|
/// 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]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user