about summary refs log tree commit diff
diff options
context:
space:
mode:
authorxizheyin <xizheyin@smail.nju.edu.cn>2025-03-31 14:53:39 +0800
committerxizheyin <xizheyin@smail.nju.edu.cn>2025-03-31 15:23:17 +0800
commit04d9d864b39c56aa6efa6b5f7845b4735d7a6428 (patch)
tree060850dd0b7f6c67d3616345bfb1d7a43198a889
parentae8ab87de4d8caab5d91a027bc19bb5d5e8a3691 (diff)
downloadrust-04d9d864b39c56aa6efa6b5f7845b4735d7a6428.tar.gz
rust-04d9d864b39c56aa6efa6b5f7845b4735d7a6428.zip
std: clarify Mutex::get_mut more clearly
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
-rw-r--r--library/std/src/sync/poison/mutex.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/library/std/src/sync/poison/mutex.rs b/library/std/src/sync/poison/mutex.rs
index 9362c764173..adb74bb6f3d 100644
--- a/library/std/src/sync/poison/mutex.rs
+++ b/library/std/src/sync/poison/mutex.rs
@@ -582,7 +582,9 @@ impl<T: ?Sized> Mutex<T> {
     /// Returns a mutable reference to the underlying data.
     ///
     /// Since this call borrows the `Mutex` mutably, no actual locking needs to
-    /// take place -- the mutable borrow statically guarantees no locks exist.
+    /// take place -- the mutable borrow statically guarantees no new locks can be acquired
+    /// while this reference exists. Note that this method does not clear any previous abandoned locks
+    /// (e.g., via [`forget()`] on a [`MutexGuard`]).
     ///
     /// # Errors
     ///
@@ -599,6 +601,8 @@ impl<T: ?Sized> Mutex<T> {
     /// *mutex.get_mut().unwrap() = 10;
     /// assert_eq!(*mutex.lock().unwrap(), 10);
     /// ```
+    ///
+    /// [`forget()`]: mem::forget
     #[stable(feature = "mutex_get_mut", since = "1.6.0")]
     pub fn get_mut(&mut self) -> LockResult<&mut T> {
         let data = self.data.get_mut();