diff options
| author | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-03-31 15:07:51 +0800 |
|---|---|---|
| committer | xizheyin <xizheyin@smail.nju.edu.cn> | 2025-04-03 19:25:38 +0800 |
| commit | ffb209710568fcb09d6971a509e6c64689da4982 (patch) | |
| tree | c948b5384511c67f30b46a1a087f0a219b699e25 | |
| parent | 04d9d864b39c56aa6efa6b5f7845b4735d7a6428 (diff) | |
| download | rust-ffb209710568fcb09d6971a509e6c64689da4982.tar.gz rust-ffb209710568fcb09d6971a509e6c64689da4982.zip | |
std: clarify RefCell::get_mut more clearly
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
| -rw-r--r-- | library/core/src/cell.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 1a320b316a4..420b0807937 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -1163,7 +1163,9 @@ impl<T: ?Sized> RefCell<T> { /// Since this method borrows `RefCell` mutably, it is statically guaranteed /// that no borrows to the underlying data exist. The dynamic checks inherent /// in [`borrow_mut`] and most other methods of `RefCell` are therefore - /// unnecessary. + /// unnecessary. Note that this method does not reset the borrowing state if borrows were previously leaked + /// (e.g., via [`forget()`] on a [`Ref`] or [`RefMut`]). For that purpose, + /// consider using the unstable [`undo_leak`] method. /// /// This method can only be called if `RefCell` can be mutably borrowed, /// which in general is only the case directly after the `RefCell` has @@ -1174,6 +1176,8 @@ impl<T: ?Sized> RefCell<T> { /// Use [`borrow_mut`] to get mutable access to the underlying data then. /// /// [`borrow_mut`]: RefCell::borrow_mut() + /// [`forget()`]: mem::forget + /// [`undo_leak`]: RefCell::undo_leak() /// /// # Examples /// |
