1
Fork 0

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.
This commit is contained in:
Otto Rask 2018-08-30 12:20:41 +03:00
parent 5399616f1d
commit 6020219993

View file

@ -49,8 +49,9 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
///
/// The type `Arc<T>` provides shared ownership of a value of type `T`,
/// allocated in the heap. Invoking [`clone`][clone] on `Arc` produces
/// a new pointer to the same `Arc` reference value in the heap. When the last
/// `Arc` pointer to a given value is destroyed, the pointed-to value is also
/// a new `Arc` instance, which points to the same value on the heap as the
/// source `Arc`, while increasing a reference count. When the last `Arc`
/// pointer to a given value is destroyed, the pointed-to value is also
/// destroyed.
///
/// Shared references in Rust disallow mutation by default, and `Arc` is no
@ -107,8 +108,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
/// // The two syntaxes below are equivalent.
/// let a = foo.clone();
/// let b = Arc::clone(&foo);
/// // a and b both point to the same memory location where foo resides
/// // (not where the value wrapped by foo resides).
/// // a and b both point to the same memory location as foo
/// ```
///
/// The [`Arc::clone(&from)`] syntax is the most idiomatic because it conveys more explicitly