From 3ad844cfe2cc130779ff876a5581b1cec02f6d3f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 18 Mar 2017 15:33:56 +0100 Subject: [PATCH] Add more explanation on RefCell::get_mut --- src/libcore/cell.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index ba04cbb0543..f62057b3a52 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -725,6 +725,15 @@ impl RefCell { /// 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 you want. In case of doubt, use [`borrow_mut`] instead. + /// + /// [`borrow_mut`]: #method.borrow_mut + /// /// # Examples /// /// ```