diff options
| author | Meltinglava <meltinglavaoutland@gmail.com> | 2018-11-13 12:20:23 +0100 |
|---|---|---|
| committer | Meltinglava <meltinglavaoutland@gmail.com> | 2018-11-13 12:20:23 +0100 |
| commit | 8b750a77fc73290635499494779f77848a8e2b09 (patch) | |
| tree | ba6361bb6e5ad9b8da3ff6a73c7ca16751066c87 | |
| parent | b937be87cb89f08235a57e07e9c73b4489dc50a1 (diff) | |
| download | rust-8b750a77fc73290635499494779f77848a8e2b09.tar.gz rust-8b750a77fc73290635499494779f77848a8e2b09.zip | |
The example values are now easyer to differenciate
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index f84e03ae765..8ebf9b2fdf5 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -2026,12 +2026,12 @@ impl<'a, K, V, S> RawEntryMut<'a, K, V, S> { /// use std::collections::HashMap; /// /// let mut map: HashMap<&str, u32> = HashMap::new(); - /// map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 12); /// - /// assert_eq!(map["poneyland"], 12); + /// map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 3); + /// assert_eq!(map["poneyland"], 3); /// - /// *map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 10).1 += 10; - /// assert_eq!(map["poneyland"], 22); + /// *map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 10).1 *= 2; + /// assert_eq!(map["poneyland"], 6); /// ``` #[unstable(feature = "hash_raw_entry", issue = "54043")] pub fn or_insert(self, default_key: K, default_val: V) -> (&'a mut K, &'a mut V) @@ -2648,12 +2648,12 @@ impl<'a, K, V> Entry<'a, K, V> { /// use std::collections::HashMap; /// /// let mut map: HashMap<&str, u32> = HashMap::new(); - /// map.entry("poneyland").or_insert(12); /// - /// assert_eq!(map["poneyland"], 12); + /// map.entry("poneyland").or_insert(3); + /// assert_eq!(map["poneyland"], 3); /// - /// *map.entry("poneyland").or_insert(10) += 10; - /// assert_eq!(map["poneyland"], 22); + /// *map.entry("poneyland").or_insert(10) *= 2; + /// assert_eq!(map["poneyland"], 6); /// ``` pub fn or_insert(self, default: V) -> &'a mut V { match self { |
