From 5f55113a6ead937fc8bc81e361abc09b3a1565f3 Mon Sep 17 00:00:00 2001 From: Botahamec Date: Thu, 26 Sep 2024 22:39:09 -0400 Subject: Reduce the number of dereferences needed --- src/poisonable/poisonable.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/poisonable/poisonable.rs') diff --git a/src/poisonable/poisonable.rs b/src/poisonable/poisonable.rs index cd135ef..ff43ff8 100644 --- a/src/poisonable/poisonable.rs +++ b/src/poisonable/poisonable.rs @@ -103,11 +103,11 @@ impl Poisonable { /// /// thread::spawn(move || { /// let key = ThreadKey::get().unwrap(); - /// **c_mutex.lock(key).unwrap() = 10; + /// *c_mutex.lock(key).unwrap() = 10; /// }).join().expect("thread::spawn failed"); /// /// let key = ThreadKey::get().unwrap(); - /// assert_eq!(**mutex.lock(key).unwrap(), 10); + /// assert_eq!(*mutex.lock(key).unwrap(), 10); /// ``` pub fn lock<'flag, 'key, Key: Keyable + 'key>( &'flag self, @@ -150,15 +150,15 @@ impl Poisonable { /// thread::spawn(move || { /// let key = ThreadKey::get().unwrap(); /// let mut lock = c_mutex.try_lock(key); - /// if let Ok(ref mut mutex) = lock { - /// ***mutex = 10; + /// if let Ok(mut mutex) = lock { + /// *mutex = 10; /// } else { /// println!("try_lock failed"); /// } /// }).join().expect("thread::spawn failed"); /// /// let key = ThreadKey::get().unwrap(); - /// assert_eq!(**mutex.lock(key).unwrap(), 10); + /// assert_eq!(*mutex.lock(key).unwrap(), 10); /// ``` /// /// [`Poisoned`]: `TryLockPoisonableError::Poisoned` @@ -187,7 +187,7 @@ impl Poisonable { /// let mutex = Poisonable::new(Mutex::new(0)); /// /// let mut guard = mutex.lock(key).unwrap(); - /// **guard += 20; + /// *guard += 20; /// /// let key = Poisonable::>::unlock(guard); /// ``` @@ -257,13 +257,13 @@ impl Poisonable { /// /// let key = ThreadKey::get().unwrap(); /// let x = mutex.lock(key).unwrap_or_else(|mut e| { - /// ***e.get_mut() = 1; + /// *e.get_mut() = 1; /// mutex.clear_poison(); /// e.into_inner() /// }); /// /// assert_eq!(mutex.is_poisoned(), false); - /// assert_eq!(**x, 1); + /// assert_eq!(*x, 1); /// ``` pub fn clear_poison(&self) { self.poisoned.clear_poison() @@ -311,7 +311,7 @@ impl Poisonable { /// let key = ThreadKey::get().unwrap(); /// let mut mutex = Poisonable::new(Mutex::new(0)); /// *mutex.get_mut().unwrap().as_mut() = 10; - /// assert_eq!(**mutex.lock(key).unwrap(), 10); + /// assert_eq!(*mutex.lock(key).unwrap(), 10); /// ``` pub fn get_mut(&mut self) -> PoisonResult<&mut L> { if self.is_poisoned() { -- cgit v1.2.3