@@ -580,15 +580,18 @@ impl<T: ?Sized> Rc<T> {
580
580
impl < T : Clone > Rc < T > {
581
581
/// Makes a mutable reference into the given `Rc`.
582
582
///
583
- /// If there are other `Rc` or [`Weak`][weak] pointers to the same value,
584
- /// then `make_mut` will invoke [`clone`][clone] on the inner value to
585
- /// ensure unique ownership. This is also referred to as clone-on-write.
583
+ /// If there are other `Rc` pointers to the same value, then `make_mut` will
584
+ /// [`clone`] the inner value to ensure unique ownership. This is also
585
+ /// referred to as clone-on-write.
586
586
///
587
- /// See also [`get_mut`][get_mut], which will fail rather than cloning.
587
+ /// If there are no other `Rc` pointers to this value, then [`Weak`]
588
+ /// pointers to this value will be dissassociated.
588
589
///
589
- /// [weak]: struct.Weak.html
590
- /// [clone]: ../../std/clone/trait.Clone.html#tymethod.clone
591
- /// [get_mut]: struct.Rc.html#method.get_mut
590
+ /// See also [`get_mut`], which will fail rather than cloning.
591
+ ///
592
+ /// [`Weak`]: struct.Weak.html
593
+ /// [`clone`]: ../../std/clone/trait.Clone.html#tymethod.clone
594
+ /// [`get_mut`]: struct.Rc.html#method.get_mut
592
595
///
593
596
/// # Examples
594
597
///
@@ -607,6 +610,23 @@ impl<T: Clone> Rc<T> {
607
610
/// assert_eq!(*data, 8);
608
611
/// assert_eq!(*other_data, 12);
609
612
/// ```
613
+ ///
614
+ /// [`Weak`] pointers will be dissassociated:
615
+ ///
616
+ /// ```
617
+ /// use std::rc::Rc;
618
+ ///
619
+ /// let mut data = Rc::new(75);
620
+ /// let weak = Rc::downgrade(&data);
621
+ ///
622
+ /// assert!(75 == *data);
623
+ /// assert!(75 == *weak.upgrade().unwrap());
624
+ ///
625
+ /// *Rc::make_mut(&mut data) += 1;
626
+ ///
627
+ /// assert!(76 == *data);
628
+ /// assert!(weak.upgrade().is_none());
629
+ /// ```
610
630
#[ inline]
611
631
#[ stable( feature = "rc_unique" , since = "1.4.0" ) ]
612
632
pub fn make_mut ( this : & mut Self ) -> & mut T {
0 commit comments