Skip to content

Commit b937be8

Browse files
committed
Clarifying documentation for collections::hash_map::Entry::or_insert
Previous version does not show that or_insert does not insert the passed value, as the passed value was the same value as what was already in the map.
1 parent 653da4f commit b937be8

File tree

1 file changed

+2
-2
lines changed
  • src/libstd/collections/hash

1 file changed

+2
-2
lines changed

src/libstd/collections/hash/map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,7 @@ impl<'a, K, V, S> RawEntryMut<'a, K, V, S> {
20302030
///
20312031
/// assert_eq!(map["poneyland"], 12);
20322032
///
2033-
/// *map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 12).1 += 10;
2033+
/// *map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 10).1 += 10;
20342034
/// assert_eq!(map["poneyland"], 22);
20352035
/// ```
20362036
#[unstable(feature = "hash_raw_entry", issue = "54043")]
@@ -2652,7 +2652,7 @@ impl<'a, K, V> Entry<'a, K, V> {
26522652
///
26532653
/// assert_eq!(map["poneyland"], 12);
26542654
///
2655-
/// *map.entry("poneyland").or_insert(12) += 10;
2655+
/// *map.entry("poneyland").or_insert(10) += 10;
26562656
/// assert_eq!(map["poneyland"], 22);
26572657
/// ```
26582658
pub fn or_insert(self, default: V) -> &'a mut V {

0 commit comments

Comments
 (0)