Skip to content

Commit 63c7721

Browse files
committed
Auto merge of rust-lang#40634 - GuillaumeGomez:refcell-docs, r=steveklabnik
Add more explanation on RefCell::get_mut Fixes rust-lang#40203. r? @rust-lang/docs
2 parents 846891a + 3ad844c commit 63c7721

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libcore/cell.rs

+9
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,15 @@ impl<T: ?Sized> RefCell<T> {
725725
/// This call borrows `RefCell` mutably (at compile-time) so there is no
726726
/// need for dynamic checks.
727727
///
728+
/// However be cautious: this method expects `self` to be mutable, which is
729+
/// generally not the case when using a `RefCell`. Take a look at the
730+
/// [`borrow_mut`] method instead if `self` isn't mutable.
731+
///
732+
/// Also, please be aware that this method is only for special circumstances and is usually
733+
/// not you want. In case of doubt, use [`borrow_mut`] instead.
734+
///
735+
/// [`borrow_mut`]: #method.borrow_mut
736+
///
728737
/// # Examples
729738
///
730739
/// ```

0 commit comments

Comments
 (0)