]> git.lizzy.rs Git - rust.git/commitdiff
Add more explanation on RefCell::get_mut
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 18 Mar 2017 14:33:56 +0000 (15:33 +0100)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 24 Apr 2017 13:08:39 +0000 (15:08 +0200)
src/libcore/cell.rs

index ba04cbb0543cd6de56de80d2412cda33e8525bfc..f62057b3a52d08c4294fe00c166755b86b6b7b64 100644 (file)
@@ -725,6 +725,15 @@ pub fn as_ptr(&self) -> *mut T {
     /// 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
     ///
     /// ```