@@ -13,6 +13,8 @@ use crate::sys::sync as sys;
1313/// For more information about mutexes, check out the documentation for the poisoning variant of
1414/// this lock (which can be found at [`poison::Mutex`]).
1515///
16+ /// [`poison::Mutex`]: crate::sync::poison::Mutex
17+ ///
1618/// # Examples
1719///
1820/// ```
@@ -143,8 +145,6 @@ use crate::sys::sync as sys;
143145///
144146/// assert_eq!(*res_mutex.lock(), 800);
145147/// ```
146- ///
147- /// [`poison::Mutex`]: crate::sync::poison::Mutex
148148#[ unstable( feature = "nonpoison_mutex" , issue = "134645" ) ]
149149#[ cfg_attr( not( test) , rustc_diagnostic_item = "NonPoisonMutex" ) ]
150150pub struct Mutex < T : ?Sized > {
@@ -226,11 +226,11 @@ unsafe impl<T: ?Sized + Sync> Sync for MutexGuard<'_, T> {}
226226/// The data protected by the mutex can be accessed through this guard via its
227227/// [`Deref`] and [`DerefMut`] implementations.
228228///
229- /// This structure is created by the [`map`] and [`try_map `] methods on
229+ /// This structure is created by the [`map`] and [`filter_map `] methods on
230230/// [`MutexGuard`].
231231///
232232/// [`map`]: MutexGuard::map
233- /// [`try_map `]: MutexGuard::try_map
233+ /// [`filter_map `]: MutexGuard::filter_map
234234/// [`Condvar`]: crate::sync::Condvar
235235#[ must_use = "if unused the Mutex will immediately unlock" ]
236236#[ must_not_suspend = "holding a MappedMutexGuard across suspend \
@@ -382,23 +382,20 @@ impl<T: ?Sized> Mutex<T> {
382382
383383 /// Attempts to acquire this lock.
384384 ///
385- /// If the lock could not be acquired at this time, then [`None`] is returned.
386- /// Otherwise, an RAII guard is returned. The lock will be unlocked when the
387- /// guard is dropped.
385+ /// This function does not block. If the lock could not be acquired at this time, then
386+ /// [`WouldBlock`] is returned. Otherwise, an RAII guard is returned.
388387 ///
389- /// This function does not block .
388+ /// The lock will be unlocked when the guard is dropped .
390389 ///
391390 /// # Errors
392391 ///
393- /// If the mutex could not be acquired because it is already locked, then
394- /// this call will return [`None`] .
392+ /// If the mutex could not be acquired because it is already locked, then this call will return
393+ /// the [`WouldBlock`] error .
395394 ///
396395 /// # Examples
397396 ///
398397 /// ```
399- /// #![feature(nonpoison_mutex)]
400- ///
401- /// use std::sync::{Arc, nonpoison::Mutex};
398+ /// use std::sync::{Arc, Mutex};
402399 /// use std::thread;
403400 ///
404401 /// let mutex = Arc::new(Mutex::new(0));
@@ -412,7 +409,7 @@ impl<T: ?Sized> Mutex<T> {
412409 /// println!("try_lock failed");
413410 /// }
414411 /// }).join().expect("thread::spawn failed");
415- /// assert_eq!(*mutex.lock(), 10);
412+ /// assert_eq!(*mutex.lock().unwrap() , 10);
416413 /// ```
417414 #[ unstable( feature = "nonpoison_mutex" , issue = "134645" ) ]
418415 pub fn try_lock ( & self ) -> TryLockResult < MutexGuard < ' _ , T > > {
@@ -567,7 +564,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> {
567564 U : ?Sized ,
568565 {
569566 // SAFETY: the conditions of `MutexGuard::new` were satisfied when the original guard
570- // was created, and have been upheld throughout `map` and/or `try_map `.
567+ // was created, and have been upheld throughout `map` and/or `filter_map `.
571568 // The signature of the closure guarantees that it will not "leak" the lifetime of the reference
572569 // passed to it. If the closure panics, the guard will be dropped.
573570 let data = NonNull :: from ( f ( unsafe { & mut * orig. lock . data . get ( ) } ) ) ;
@@ -582,17 +579,16 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> {
582579 /// The `Mutex` is already locked, so this cannot fail.
583580 ///
584581 /// This is an associated function that needs to be used as
585- /// `MutexGuard::try_map (...)`. A method would interfere with methods of the
582+ /// `MutexGuard::filter_map (...)`. A method would interfere with methods of the
586583 /// same name on the contents of the `MutexGuard` used through `Deref`.
587- #[ doc( alias = "filter_map" ) ]
588584 #[ unstable( feature = "mapped_lock_guards" , issue = "117108" ) ]
589- pub fn try_map < U , F > ( orig : Self , f : F ) -> Result < MappedMutexGuard < ' a , U > , Self >
585+ pub fn filter_map < U , F > ( orig : Self , f : F ) -> Result < MappedMutexGuard < ' a , U > , Self >
590586 where
591587 F : FnOnce ( & mut T ) -> Option < & mut U > ,
592588 U : ?Sized ,
593589 {
594590 // SAFETY: the conditions of `MutexGuard::new` were satisfied when the original guard
595- // was created, and have been upheld throughout `map` and/or `try_map `.
591+ // was created, and have been upheld throughout `map` and/or `filter_map `.
596592 // The signature of the closure guarantees that it will not "leak" the lifetime of the reference
597593 // passed to it. If the closure panics, the guard will be dropped.
598594 match f ( unsafe { & mut * orig. lock . data . get ( ) } ) {
0 commit comments