Uh oh!
There was an error while loading. Please reload this page.
Add more explanation on RefCell::get_mut - #40634
Conversation
bb40d11 to
52cf2a9Comparesteveklabnik
commented
Mar 23, 2017
I think the real issue with #40203 is
That is, we need to explain when you would use this method, not just point out that it needs mutable self. |
carols10cents
commented
Apr 17, 2017
Hi @GuillaumeGomez! It looks like @steveklabnik is suggesting some changes to this PR. Just wanted to send a ping to keep this on your radar! |
52cf2a9 to
0b9009eCompareGuillaumeGomez
commented
Apr 19, 2017
Updated (finally!). |
Nevermind, errors are network related. Restarted the build. |
steveklabnik
commented
Apr 24, 2017
@bors: r+ rollup |
bors
commented
Apr 24, 2017
📌 Commit 0b9009e has been approved by |
bors
commented
Apr 24, 2017
🔒 Merge conflict |
0b9009e to
3ad844cCompareGuillaumeGomez
commented
Apr 24, 2017
Not sure what went wrong in here... I rebased just in case. @bors: r=steveklabnik rollup |
bors
commented
Apr 24, 2017
📌 Commit 3ad844c has been approved by |
bors
commented
Apr 24, 2017
Add more explanation on RefCell::get_mut Fixes#40203. r? @rust-lang/docs
bors
commented
Apr 24, 2017
☀️ Test successful - status-appveyor, status-travis |
Tone down explanation on RefCell::get_mut
The language around `RefCell::get_mut` is remarkably sketchy and especially to the novice seems to quite strongly discourage using the method ("be cautious", "Also, please be aware", "special circumstances", "usually not what you want"). It was added six years ago in rust-lang#40634 due to confusion about when to use `get_mut` and `borrow_mut`.
While its signature limits the use-cases for `get_mut`, there is no chance for a safety footgun, and readers can be made aware of `borrow_mut` more softly. I've also just sent a [PR](rust-lang/rust-clippy#9044) to lint situations where `get_mut` could be used to improve ergonomics and performance.
So this PR tones down the language around `get_mut` and also brings it more in line with [`std::sync::Mutex::get_mut()`](https://doc.rust-lang.org/stable/std/sync/struct.Mutex.html#method.get_mut).Tone down explanation on RefCell::get_mut
The language around `RefCell::get_mut` is remarkably sketchy and especially to the novice seems to quite strongly discourage using the method ("be cautious", "Also, please be aware", "special circumstances", "usually not what you want"). It was added six years ago in rust-lang#40634 due to confusion about when to use `get_mut` and `borrow_mut`.
While its signature limits the use-cases for `get_mut`, there is no chance for a safety footgun, and readers can be made aware of `borrow_mut` more softly. I've also just sent a [PR](rust-lang/rust-clippy#9044) to lint situations where `get_mut` could be used to improve ergonomics and performance.
So this PR tones down the language around `get_mut` and also brings it more in line with [`std::sync::Mutex::get_mut()`](https://doc.rust-lang.org/stable/std/sync/struct.Mutex.html#method.get_mut).
Fixes#40203.
r? @rust-lang/docs