rust/library
Yuki Okushi 90e82c950b
Rollup merge of #86397 - Eosis:alter-cell-docs, r=JohnTitor
Alter std::cell::Cell::get_mut documentation

I felt that there was some inconsistency between between Cell and RefCell with regards to their `get_mut` method documentation: `RefCell` flags this method as "unusual" in that it takes `&mut self`, while `Cell` does not. I attempted to flag this in `Cell`s documentation as well, and point to `RefCell`s method in the case where it is required.

Find relevant parts of docs and the new version below.

The current docs for `Cell::get_mut`:
> Returns a mutable reference to the underlying data.
This call borrows Cell mutably (at compile-time) which guarantees that we possess the only reference.

And `RefCell::get_mut`:
> Returns a mutable reference to the underlying data.
 This call borrows `RefCell` mutably (at compile-time) so there is no need for dynamic checks.
However be cautious: this method expects self to be mutable, which is generally not the case when using a `RefCell`. Take a look at the `borrow_mut` method instead if self isn’t mutable.
Also, please be aware that this method is only for special circumstances and is usually not what you want. In case of doubt, use `borrow_mut` instead.

My attempt to make `Cell::get_mut` clearer:
> Returns a mutable reference to the underlying data.
This call borrows `Cell` mutably (at compile-time) which guaranteesthat we possess the only reference.
However be cautious: this method expects `self` to be mutable, which is generally not the case when using a `Cell`. If you require interior mutability by reference, consider using `RefCell` which provides run-time checked mutable borrows through its `borrow_mut` method.
2021-06-19 10:14:10 +09:00
..
alloc Rollup merge of #85970 - jsha:remove-methods-implementors, r=GuillaumeGomez 2021-06-17 21:56:42 +09:00
backtrace@221483ebaf
core Rollup merge of #86397 - Eosis:alter-cell-docs, r=JohnTitor 2021-06-19 10:14:10 +09:00
panic_abort rustdoc: link to stable/beta docs consistently in documentation 2021-06-04 14:18:21 -04:00
panic_unwind rustdoc: link to stable/beta docs consistently in documentation 2021-06-04 14:18:21 -04:00
proc_macro Rollup merge of #86136 - m-ou-se:proc-macro-open-close-span, r=m-ou-se 2021-06-19 10:14:07 +09:00
profiler_builtins Update cc 2021-05-24 23:34:12 +01:00
rtstartup
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Auto merge of #85815 - YuhanLiin:buf-read-data-left, r=m-ou-se 2021-06-18 20:11:51 +00:00
stdarch@3001c75a1d Update stdarch submodule to stabilize simd_x86_bittest feature 2021-06-13 02:29:17 +09:00
term rustdoc: link to stable/beta docs consistently in documentation 2021-06-04 14:18:21 -04:00
test Use as_secs_f64 in JunitFormatter 2021-06-17 03:23:17 +08:00
unwind Support Android ndk versions r23-beta3 and up 2021-06-01 21:37:50 +02:00