File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -387,14 +387,19 @@ impl<T: ?Sized> Mutex<T> {
387387 /// panic!(); // the mutex gets poisoned
388388 /// }).join();
389389 ///
390- /// let guard = mutex.lock().unwrap_err().into_inner();
391- /// Mutex::clear_poison(&guard);
390+ /// assert_eq!(mutex.is_poisoned(), true);
391+ /// let x = mutex.lock().unwrap_or_else(|mut e| {
392+ /// **e.get_mut() = 1;
393+ /// mutex.clear_poison();
394+ /// e.into_inner()
395+ /// });
392396 /// assert_eq!(mutex.is_poisoned(), false);
397+ /// assert_eq!(*x, 1);
393398 /// ```
394399 #[ inline]
395400 #[ unstable( feature = "mutex_unpoison" , issue = "96469" ) ]
396- pub fn clear_poison ( guard : & MutexGuard < ' _ , T > ) {
397- guard . lock . poison . clear ( ) ;
401+ pub fn clear_poison ( & self ) {
402+ self . poison . clear ( ) ;
398403 }
399404
400405 /// Consumes this mutex, returning the underlying data.
Original file line number Diff line number Diff line change @@ -390,14 +390,19 @@ impl<T: ?Sized> RwLock<T> {
390390 /// panic!(); // the mutex gets poisoned
391391 /// }).join();
392392 ///
393- /// let guard = lock.write().unwrap_err().into_inner();
394- /// RwLock::clear_poison(&guard);
393+ /// assert_eq!(lock.is_poisoned(), true);
394+ /// let guard = lock.write().unwrap_or_else(|mut e| {
395+ /// **e.get_mut() = 1;
396+ /// lock.clear_poison();
397+ /// e.into_inner()
398+ /// });
395399 /// assert_eq!(lock.is_poisoned(), false);
400+ /// assert_eq!(*guard, 1);
396401 /// ```
397402 #[ inline]
398403 #[ unstable( feature = "mutex_unpoison" , issue = "96469" ) ]
399- pub fn clear_poison ( guard : & RwLockWriteGuard < ' _ , T > ) {
400- guard . lock . poison . clear ( ) ;
404+ pub fn clear_poison ( & self ) {
405+ self . poison . clear ( ) ;
401406 }
402407
403408 /// Consumes this `RwLock`, returning the underlying data.
You can’t perform that action at this time.
0 commit comments