Skip to content

Commit 6020219

Browse files
committed
Rephrase Arc documentation changes regarding clones
Make it clearer that `Arc::clone()` in fact creates a whole new Arc with the internal pointer pointing to the same location as the source Arc.
1 parent 5399616 commit 6020219

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/liballoc/sync.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
4949
///
5050
/// The type `Arc<T>` provides shared ownership of a value of type `T`,
5151
/// allocated in the heap. Invoking [`clone`][clone] on `Arc` produces
52-
/// a new pointer to the same `Arc` reference value in the heap. When the last
53-
/// `Arc` pointer to a given value is destroyed, the pointed-to value is also
52+
/// a new `Arc` instance, which points to the same value on the heap as the
53+
/// source `Arc`, while increasing a reference count. When the last `Arc`
54+
/// pointer to a given value is destroyed, the pointed-to value is also
5455
/// destroyed.
5556
///
5657
/// Shared references in Rust disallow mutation by default, and `Arc` is no
@@ -107,8 +108,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
107108
/// // The two syntaxes below are equivalent.
108109
/// let a = foo.clone();
109110
/// let b = Arc::clone(&foo);
110-
/// // a and b both point to the same memory location where foo resides
111-
/// // (not where the value wrapped by foo resides).
111+
/// // a and b both point to the same memory location as foo
112112
/// ```
113113
///
114114
/// The [`Arc::clone(&from)`] syntax is the most idiomatic because it conveys more explicitly

0 commit comments

Comments
 (0)