diff options
| author | bors <bors@rust-lang.org> | 2018-06-03 03:13:43 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-06-03 03:13:43 +0000 |
| commit | 3575be60eab140e69e5a75fe5c3b4119c2a17179 (patch) | |
| tree | d34f9307f8f807c7dfad8d81bac4e5fc5fffabb9 /src/liballoc | |
| parent | 251ec62a134824c1b8c01671a2d05aa793839232 (diff) | |
| parent | c09cad1f28135d019231c171d631e608c7b39f0e (diff) | |
| download | rust-3575be60eab140e69e5a75fe5c3b4119c2a17179.tar.gz rust-3575be60eab140e69e5a75fe5c3b4119c2a17179.zip | |
Auto merge of #51319 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 6 pull requests Successful merges: - #51143 (Specify that packed types must derive, not implement, Copy) - #51226 (Make Layout's align a NonZeroUsize) - #51297 (Fix run button style) - #51306 (impl Default for &mut str) - #51312 (Clarify the difference between get_mut and into_mut for OccupiedEntry) - #51313 (use type name in E0599 enum variant suggestion) Failed merges:
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/btree/map.rs | 17 | ||||
| -rw-r--r-- | src/liballoc/tests/str.rs | 1 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/liballoc/btree/map.rs b/src/liballoc/btree/map.rs index 28c42144b2a..9b6f91c039f 100644 --- a/src/liballoc/btree/map.rs +++ b/src/liballoc/btree/map.rs @@ -2369,6 +2369,11 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> { /// Gets a mutable reference to the value in the entry. /// + /// If you need a reference to the `OccupiedEntry` which may outlive the + /// destruction of the `Entry` value, see [`into_mut`]. + /// + /// [`into_mut`]: #method.into_mut + /// /// # Examples /// /// ``` @@ -2380,9 +2385,13 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> { /// /// assert_eq!(map["poneyland"], 12); /// if let Entry::Occupied(mut o) = map.entry("poneyland") { - /// *o.get_mut() += 10; + /// *o.get_mut() += 10; + /// assert_eq!(*o.get(), 22); + /// + /// // We can use the same Entry multiple times. + /// *o.get_mut() += 2; /// } - /// assert_eq!(map["poneyland"], 22); + /// assert_eq!(map["poneyland"], 24); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn get_mut(&mut self) -> &mut V { @@ -2391,6 +2400,10 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> { /// Converts the entry into a mutable reference to its value. /// + /// If you need multiple references to the `OccupiedEntry`, see [`get_mut`]. + /// + /// [`get_mut`]: #method.get_mut + /// /// # Examples /// /// ``` diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index 03d295d16e6..75306ac82df 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -1326,6 +1326,7 @@ fn test_str_default() { t::<&str>(); t::<String>(); + t::<&mut str>(); } #[test] |
