std: clarify RefCell::get_mut more clearly

Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
This commit is contained in:
xizheyin 2025-03-31 15:07:51 +08:00
parent 04d9d864b3
commit ffb2097105
No known key found for this signature in database
GPG key ID: 0A0D90BE99CEDEAD

View file

@ -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
///