-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
New Cell docs #48474
New Cell docs #48474
Changes from 7 commits
238bb38
f9e049a
58d1f83
43de01f
ce3ad26
7ded7f7
397ce8a
9091584
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 |
---|---|---|
|
@@ -10,6 +10,23 @@ | |
|
||
//! Shareable mutable containers. | ||
//! | ||
//! Rust memory safety is based on this rule: Given an object `T`, it is only possible to | ||
//! have one of the following: | ||
//! | ||
//! - Having several immutable references (`&T`) to the object (also know as Aliasing). | ||
//! - Having one mutable reference (`&mut T`) to the object (also know as Mutability). | ||
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.
|
||
//! | ||
//! This is enforced by the Rust compiler. However, there are situations where this rule is not | ||
//! flexible enough. Sometimes it is required to have multiple references to an object and yet | ||
//! mutate it. | ||
//! | ||
//! Shareable mutable containers exist to permit mutability in the presence of aliasing in a | ||
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. "in ___ in ___" reads a bit awkward. I might write: Before: ...to permit mutability in the presence of aliasing in a controlled manner |
||
//! controlled manner. Both `Cell<T>` and `RefCell<T>` allows to do this in a single threaded | ||
//! way. However, neither `Cell<T>` nor `RefCell<T>` are thread safe (they do not implement | ||
//! `Sync`), if you need to do Aliasing and Mutation between multiple threads is possible to use | ||
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. Use period instead of comma after these parentheses.
|
||
//! [`Mutex`](../../std/sync/struct.Mutex.html), [`RwLock`](../../std/sync/struct.RwLock.html) or | ||
//! [`atomic`](../../core/sync/atomic/index.html) types. | ||
//! | ||
//! Values of the `Cell<T>` and `RefCell<T>` types may be mutated through shared references (i.e. | ||
//! the common `&T` type), whereas most Rust types can only be mutated through unique (`&mut T`) | ||
//! references. We say that `Cell<T>` and `RefCell<T>` provide 'interior mutability', in contrast | ||
|
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.
s/know as/known as/
s/Aliasing/**aliasing**/
. Capitalization of common nouns is unnatural in English, and when it is done, it generally implies that the capitalized noun has a much more specific (and widely understood) definition than the lowercase noun (e.g. "Undefined Behavior" is not the same thing as "undefined behavior"). This is unnecessary for a word like "aliasing" which is already uncommon.The reason I suggest bold here is because you are introducing a definition for it.