diff options
| author | Botahamec <botahamec@outlook.com> | 2024-09-26 22:39:09 -0400 |
|---|---|---|
| committer | Botahamec <botahamec@outlook.com> | 2024-09-26 22:39:09 -0400 |
| commit | 5f55113a6ead937fc8bc81e361abc09b3a1565f3 (patch) | |
| tree | a8858abcb05d3796aec89e0fddff5e9ab18a873d /src/poisonable/poisonable.rs | |
| parent | af4013c53e12bfad11bc33c060532320e33729a7 (diff) | |
Reduce the number of dereferences needed
Diffstat (limited to 'src/poisonable/poisonable.rs')
| -rw-r--r-- | src/poisonable/poisonable.rs | 18 |
1 files changed, 9 insertions, 9 deletions
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<L: Lockable + RawLock> Poisonable<L> { /// /// 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<L: Lockable + RawLock> Poisonable<L> { /// 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<L: Lockable + RawLock> Poisonable<L> { /// let mutex = Poisonable::new(Mutex::new(0)); /// /// let mut guard = mutex.lock(key).unwrap(); - /// **guard += 20; + /// *guard += 20; /// /// let key = Poisonable::<Mutex<_>>::unlock(guard); /// ``` @@ -257,13 +257,13 @@ impl<L: Lockable + RawLock> Poisonable<L> { /// /// 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<L: Lockable + RawLock> Poisonable<L> { /// 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() { |
