@@ -2369,6 +2369,11 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
23692369
23702370 /// Gets a mutable reference to the value in the entry.
23712371 ///
2372+ /// If you need a reference to the `OccupiedEntry` which may outlive the
2373+ /// destruction of the `Entry` value, see [`into_mut`].
2374+ ///
2375+ /// [`into_mut`]: #method.into_mut
2376+ ///
23722377 /// # Examples
23732378 ///
23742379 /// ```
@@ -2380,9 +2385,13 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
23802385 ///
23812386 /// assert_eq!(map["poneyland"], 12);
23822387 /// if let Entry::Occupied(mut o) = map.entry("poneyland") {
2383- /// *o.get_mut() += 10;
2388+ /// *o.get_mut() += 10;
2389+ /// assert_eq!(*o.get(), 22);
2390+ ///
2391+ /// // We can use the same Entry multiple times.
2392+ /// *o.get_mut() += 2;
23842393 /// }
2385- /// assert_eq!(map["poneyland"], 22 );
2394+ /// assert_eq!(map["poneyland"], 24 );
23862395 /// ```
23872396 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
23882397 pub fn get_mut ( & mut self ) -> & mut V {
@@ -2391,6 +2400,10 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
23912400
23922401 /// Converts the entry into a mutable reference to its value.
23932402 ///
2403+ /// If you need multiple references to the `OccupiedEntry`, see [`get_mut`].
2404+ ///
2405+ /// [`get_mut`]: #method.get_mut
2406+ ///
23942407 /// # Examples
23952408 ///
23962409 /// ```
0 commit comments