@@ -2369,6 +2369,11 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
2369
2369
2370
2370
/// Gets a mutable reference to the value in the entry.
2371
2371
///
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
+ ///
2372
2377
/// # Examples
2373
2378
///
2374
2379
/// ```
@@ -2380,9 +2385,13 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
2380
2385
///
2381
2386
/// assert_eq!(map["poneyland"], 12);
2382
2387
/// 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;
2384
2393
/// }
2385
- /// assert_eq!(map["poneyland"], 22 );
2394
+ /// assert_eq!(map["poneyland"], 24 );
2386
2395
/// ```
2387
2396
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2388
2397
pub fn get_mut ( & mut self ) -> & mut V {
@@ -2391,6 +2400,10 @@ impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
2391
2400
2392
2401
/// Converts the entry into a mutable reference to its value.
2393
2402
///
2403
+ /// If you need multiple references to the `OccupiedEntry`, see [`get_mut`].
2404
+ ///
2405
+ /// [`get_mut`]: #method.get_mut
2406
+ ///
2394
2407
/// # Examples
2395
2408
///
2396
2409
/// ```
0 commit comments