Skip to content
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

Merged
merged 8 commits into from
Mar 6, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@

//! Shareable mutable containers.
//!
//! Rust memory safety is based on this rule: Given an object `T`, is only possible to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing "it"

//! have one of the following:
//!
//! - Having several inmutable references (`&T`) to the object (also know as Aliasing).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/inmutable/immutable

//! - Having one mutable reference (`&mut T`) to the object (also know as Mutability).
Copy link
Contributor

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/Mutability/**mutability**/

//!
//! This is enforced by the Rust compiler. However, there are situations where this rule is not
//! flexible enough. Sometimes is required to have multiple references to an object and yet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing "it"

//! mutate it.
//!
//! Shareable mutable containers exist to permit mutability in presence of aliasing in a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be "in the presence"

//! 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use period instead of comma after these parentheses.
Add comma after "threads".
Missing "it" before "is possible."
Don't capitalize (or emphasize) aliasing and mutation.

Sync). If you need to do aliasing and mutation between multiple threads, it is possible to use

//! `Mutex`, `RwLock` or `AtomicXXX`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably link to these types here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'll do it :)

//!
//! 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
Expand Down