Skip to content

Commit b7bebe1

Browse files
committed
std: clarify RefCell::get_mut more clearly
Signed-off-by: xizheyin <[email protected]>
1 parent 04d9d86 commit b7bebe1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/core/src/cell.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,9 @@ impl<T: ?Sized> RefCell<T> {
11631163
/// Since this method borrows `RefCell` mutably, it is statically guaranteed
11641164
/// that no borrows to the underlying data exist. The dynamic checks inherent
11651165
/// in [`borrow_mut`] and most other methods of `RefCell` are therefore
1166-
/// unnecessary.
1166+
/// unnecessary. Note that this method does not reset the borrowing state if borrows were previously leaked
1167+
/// (e.g., via [`forget()`] on a [`Ref`] or [`RefMut`]). For that purpose,
1168+
/// consider using the unstable `undo_leak` method.
11671169
///
11681170
/// This method can only be called if `RefCell` can be mutably borrowed,
11691171
/// which in general is only the case directly after the `RefCell` has
@@ -1174,6 +1176,7 @@ impl<T: ?Sized> RefCell<T> {
11741176
/// Use [`borrow_mut`] to get mutable access to the underlying data then.
11751177
///
11761178
/// [`borrow_mut`]: RefCell::borrow_mut()
1179+
/// [`forget()`]: mem::forget
11771180
///
11781181
/// # Examples
11791182
///

0 commit comments

Comments
 (0)