|
25 | 25 | //! to an [`Rc`], but this will return [`None`] if the value stored in the allocation has
|
26 | 26 | //! already been dropped. In other words, `Weak` pointers do not keep the value
|
27 | 27 | //! inside the allocation alive; however, they *do* keep the allocation
|
28 |
| -//! (the backing store for the value) alive. |
| 28 | +//! (the backing store for the inner value) alive. |
29 | 29 | //!
|
30 | 30 | //! A cycle between [`Rc`] pointers will never be deallocated. For this reason,
|
31 | 31 | //! [`Weak`] is used to break cycles. For example, a tree could have strong
|
|
44 | 44 | //! Rc::downgrade(&my_rc);
|
45 | 45 | //! ```
|
46 | 46 | //!
|
47 |
| -//! [`Weak<T>`][`Weak`] does not auto-dereference to `T`, because the allocation may have |
48 |
| -//! already been destroyed. |
| 47 | +//! [`Weak<T>`][`Weak`] does not auto-dereference to `T`, because the inner value may have |
| 48 | +//! already been dropped. |
49 | 49 | //!
|
50 | 50 | //! # Cloning references
|
51 | 51 | //!
|
@@ -449,7 +449,7 @@ impl<T> Rc<mem::MaybeUninit<T>> {
|
449 | 449 | /// # Safety
|
450 | 450 | ///
|
451 | 451 | /// As with [`MaybeUninit::assume_init`],
|
452 |
| - /// it is up to the caller to guarantee that the value |
| 452 | + /// it is up to the caller to guarantee that the inner value |
453 | 453 | /// really is in an initialized state.
|
454 | 454 | /// Calling this when the content is not yet fully initialized
|
455 | 455 | /// causes immediate undefined behavior.
|
@@ -488,7 +488,7 @@ impl<T> Rc<[mem::MaybeUninit<T>]> {
|
488 | 488 | /// # Safety
|
489 | 489 | ///
|
490 | 490 | /// As with [`MaybeUninit::assume_init`],
|
491 |
| - /// it is up to the caller to guarantee that the value |
| 491 | + /// it is up to the caller to guarantee that the inner value |
492 | 492 | /// really is in an initialized state.
|
493 | 493 | /// Calling this when the content is not yet fully initialized
|
494 | 494 | /// causes immediate undefined behavior.
|
@@ -883,7 +883,7 @@ impl Rc<dyn Any> {
|
883 | 883 |
|
884 | 884 | impl<T: ?Sized> Rc<T> {
|
885 | 885 | /// Allocates an `RcBox<T>` with sufficient space for
|
886 |
| - /// a possibly-unsized value where the value has the layout provided. |
| 886 | + /// a possibly-unsized inner value where the value has the layout provided. |
887 | 887 | ///
|
888 | 888 | /// The function `mem_to_rcbox` is called with the data pointer
|
889 | 889 | /// and must return back a (potentially fat)-pointer for the `RcBox<T>`.
|
@@ -913,7 +913,7 @@ impl<T: ?Sized> Rc<T> {
|
913 | 913 | inner
|
914 | 914 | }
|
915 | 915 |
|
916 |
| - /// Allocates an `RcBox<T>` with sufficient space for an unsized value |
| 916 | + /// Allocates an `RcBox<T>` with sufficient space for an unsized inner value |
917 | 917 | unsafe fn allocate_for_ptr(ptr: *const T) -> *mut RcBox<T> {
|
918 | 918 | // Allocate for the `RcBox<T>` using the given value.
|
919 | 919 | Self::allocate_for_layout(
|
@@ -1177,6 +1177,8 @@ impl<T: ?Sized + PartialEq> RcEqIdent<T> for Rc<T> {
|
1177 | 1177 | /// store large values, that are slow to clone, but also heavy to check for equality, causing this
|
1178 | 1178 | /// cost to pay off more easily. It's also more likely to have two `Rc` clones, that point to
|
1179 | 1179 | /// the same value, than two `&T`s.
|
| 1180 | +/// |
| 1181 | +/// We can only do this when `T: Eq` as a `PartialEq` might be deliberately irreflexive. |
1180 | 1182 | #[stable(feature = "rust1", since = "1.0.0")]
|
1181 | 1183 | impl<T: ?Sized + Eq> RcEqIdent<T> for Rc<T> {
|
1182 | 1184 | #[inline]
|
@@ -1759,10 +1761,10 @@ pub(crate) fn is_dangling<T: ?Sized>(ptr: NonNull<T>) -> bool {
|
1759 | 1761 | }
|
1760 | 1762 |
|
1761 | 1763 | impl<T: ?Sized> Weak<T> {
|
1762 |
| - /// Attempts to upgrade the `Weak` pointer to an [`Rc`], extending |
1763 |
| - /// the lifetime of the allocation if successful. |
| 1764 | + /// Attempts to upgrade the `Weak` pointer to an [`Rc`], delaying |
| 1765 | + /// dropping of the inner value if successful. |
1764 | 1766 | ///
|
1765 |
| - /// Returns [`None`] if the value stored in the allocation has since been dropped. |
| 1767 | + /// Returns [`None`] if the inner value has since been dropped. |
1766 | 1768 | ///
|
1767 | 1769 | /// [`Rc`]: struct.Rc.html
|
1768 | 1770 | /// [`None`]: ../../std/option/enum.Option.html
|
|
0 commit comments