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

New Cell docs #48474

merged 8 commits into from
Mar 6, 2018

Conversation

pvdrz
Copy link
Contributor

@pvdrz pvdrz commented Feb 23, 2018

This fixes #44061

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 23, 2018
//! Rust memory safety is based on this rule: Given an object `T`, is only possible to
//! 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

//! 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
//! `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 :)

@Mark-Simulacrum
Copy link
Member

r? @steveklabnik

@@ -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"

//! - Having one mutable reference (`&mut T`) to the object (also know as 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"

//! flexible enough. Sometimes is required to have multiple references to an object and yet
//! 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"

@pvdrz
Copy link
Contributor Author

pvdrz commented Feb 24, 2018

Ok I've done the pertinent changes! Thank you all for your feedback :)

Copy link
Contributor

@ExpHP ExpHP left a comment

Choose a reason for hiding this comment

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

Just some grammar nits.

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

@ExpHP ExpHP Feb 26, 2018

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.

//! 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).
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**/

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

Choose a reason for hiding this comment

The 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
After: ...to permit mutability in a controlled manner, even in the presence of aliasing.

//! Shareable mutable containers exist to permit mutability in the presence of aliasing in a
//! 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

@shepmaster
Copy link
Member

Ping from triage, @steveklabnik !

@steveklabnik
Copy link
Member

I am not likely to be able to review until late tomorrow, possibly tuesday. Sorry about that!

@steveklabnik
Copy link
Member

@bors: r+ rollup

So sorry about the delay, this is great. Thanks so much!

@bors
Copy link
Contributor

bors commented Mar 6, 2018

📌 Commit 9091584 has been approved by steveklabnik

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 6, 2018
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Mar 6, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Mar 6, 2018
bors added a commit that referenced this pull request Mar 6, 2018
Rollup of 14 pull requests

- Successful merges: #48403, #48432, #48546, #48573, #48590, #48657, #48727, #48732, #48753, #48754, #48761, #48474, #48507, #47463
- Failed merges:
@alexcrichton alexcrichton merged commit 9091584 into rust-lang:master Mar 6, 2018
@pvdrz pvdrz deleted the new_cell_docs branch March 6, 2018 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorporate ideas from StackOverflow cell/reference answer into std::cell docs
9 participants