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