-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Arc cloning mechanics clearer in module docs #53782
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,9 +49,10 @@ 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 value in the heap. When the last `Arc` | ||
/// pointer to a given value is destroyed, the pointed-to value is | ||
/// also destroyed. | ||
/// 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 | ||
/// exception: you cannot generally obtain a mutable reference to something | ||
|
@@ -107,7 +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 as foo. | ||
/// // a and b both point to the same memory location as foo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this still sounds confusing you could say "a and b both point to the same memory location as foo does" or "a, b, and foo all point to the same memory location" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, I probably should make that change to make it even clearer. I know for a fact that folks with English as a second language do appreciate the extra wording. |
||
/// ``` | ||
/// | ||
/// The [`Arc::clone(&from)`] syntax is the most idiomatic because it conveys more explicitly | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds better now!