diff options
| -rw-r--r-- | src/collection.rs | 8 | ||||
| -rw-r--r-- | src/collection/guard.rs | 12 | ||||
| -rw-r--r-- | src/collection/ref.rs | 20 | ||||
| -rw-r--r-- | src/lockable.rs | 128 | ||||
| -rw-r--r-- | src/mutex.rs | 2 | ||||
| -rw-r--r-- | src/mutex/guard.rs | 7 | ||||
| -rw-r--r-- | src/mutex/mutex.rs | 9 | ||||
| -rw-r--r-- | src/poisonable/error.rs | 6 | ||||
| -rw-r--r-- | src/poisonable/guard.rs | 30 | ||||
| -rw-r--r-- | src/rwlock/read_lock.rs | 10 | ||||
| -rw-r--r-- | src/rwlock/rwlock.rs | 10 | ||||
| -rw-r--r-- | src/rwlock/write_lock.rs | 10 |
12 files changed, 162 insertions, 90 deletions
diff --git a/src/collection.rs b/src/collection.rs index 9e88062..a8ae0b7 100644 --- a/src/collection.rs +++ b/src/collection.rs @@ -52,11 +52,11 @@ pub struct OwnedLockCollection<L> { /// /// [`Lockable`]: `crate::lockable::Lockable` /// [`OwnedLockable`]: `crate::lockable::OwnedLockable` - +// // This type was born when I eventually realized that I needed a self // referential structure. That used boxing, so I elected to make a more // efficient implementation (polonius please save us) - +// // This type caches the sorting order of the locks and the fact that it doesn't // contain any duplicates. pub struct RefLockCollection<'a, L> { @@ -82,7 +82,7 @@ pub struct RefLockCollection<'a, L> { /// /// [`Lockable`]: `crate::lockable::Lockable` /// [`OwnedLockable`]: `crate::lockable::OwnedLockable` - +// // This type caches the sorting order of the locks and the fact that it doesn't // contain any duplicates. pub struct BoxedLockCollection<L> { @@ -112,7 +112,7 @@ pub struct BoxedLockCollection<L> { /// [`Lockable`]: `crate::lockable::Lockable` /// [`OwnedLockable`]: `crate::lockable::OwnedLockable` /// [livelocking]: https://en.wikipedia.org/wiki/Deadlock#Livelock - +// // This type caches the fact that there are no duplicates #[derive(Debug)] pub struct RetryingLockCollection<L> { diff --git a/src/collection/guard.rs b/src/collection/guard.rs index 0b8a583..70bb3a6 100644 --- a/src/collection/guard.rs +++ b/src/collection/guard.rs @@ -5,19 +5,19 @@ use crate::key::Keyable; use super::LockGuard; -impl<'key, Guard: Debug, Key: Keyable> Debug for LockGuard<'key, Guard, Key> { +impl<Guard: Debug, Key: Keyable> Debug for LockGuard<'_, Guard, Key> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(&**self, f) } } -impl<'key, Guard: Display, Key: Keyable> Display for LockGuard<'key, Guard, Key> { +impl<Guard: Display, Key: Keyable> Display for LockGuard<'_, Guard, Key> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&**self, f) } } -impl<'key, Guard, Key: Keyable> Deref for LockGuard<'key, Guard, Key> { +impl<Guard, Key: Keyable> Deref for LockGuard<'_, Guard, Key> { type Target = Guard; fn deref(&self) -> &Self::Target { @@ -25,19 +25,19 @@ impl<'key, Guard, Key: Keyable> Deref for LockGuard<'key, Guard, Key> { } } -impl<'key, Guard, Key: Keyable> DerefMut for LockGuard<'key, Guard, Key> { +impl<Guard, Key: Keyable> DerefMut for LockGuard<'_, Guard, Key> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.guard } } -impl<'key, Guard, Key: Keyable> AsRef<Guard> for LockGuard<'key, Guard, Key> { +impl<Guard, Key: Keyable> AsRef<Guard> for LockGuard<'_, Guard, Key> { fn as_ref(&self) -> &Guard { &self.guard } } -impl<'key, Guard, Key: Keyable> AsMut<Guard> for LockGuard<'key, Guard, Key> { +impl<Guard, Key: Keyable> AsMut<Guard> for LockGuard<'_, Guard, Key> { fn as_mut(&mut self) -> &mut Guard { &mut self.guard } diff --git a/src/collection/ref.rs b/src/collection/ref.rs index 60abdfa..7c0d40a 100644 --- a/src/collection/ref.rs +++ b/src/collection/ref.rs @@ -26,7 +26,7 @@ fn contains_duplicates(l: &[&dyn RawLock]) -> bool { .any(|window| std::ptr::eq(window[0], window[1])) } -impl<'a, L> AsRef<L> for RefLockCollection<'a, L> { +impl<L> AsRef<L> for RefLockCollection<'_, L> { fn as_ref(&self) -> &L { self.data } @@ -44,7 +44,7 @@ where } } -unsafe impl<'a, L: Lockable + Send + Sync> RawLock for RefLockCollection<'a, L> { +unsafe impl<L: Lockable + Send + Sync> RawLock for RefLockCollection<'_, L> { unsafe fn lock(&self) { for lock in &self.locks { lock.lock(); @@ -78,10 +78,16 @@ unsafe impl<'a, L: Lockable + Send + Sync> RawLock for RefLockCollection<'a, L> } } -unsafe impl<'c, L: Lockable> Lockable for RefLockCollection<'c, L> { - type Guard<'g> = L::Guard<'g> where Self: 'g; +unsafe impl<L: Lockable> Lockable for RefLockCollection<'_, L> { + type Guard<'g> + = L::Guard<'g> + where + Self: 'g; - type ReadGuard<'g> = L::ReadGuard<'g> where Self: 'g; + type ReadGuard<'g> + = L::ReadGuard<'g> + where + Self: 'g; fn get_ptrs<'a>(&'a self, ptrs: &mut Vec<&'a dyn RawLock>) { ptrs.extend_from_slice(&self.locks); @@ -96,9 +102,9 @@ unsafe impl<'c, L: Lockable> Lockable for RefLockCollection<'c, L> { } } -unsafe impl<'c, L: Sharable> Sharable for RefLockCollection<'c, L> {} +unsafe impl<L: Sharable> Sharable for RefLockCollection<'_, L> {} -impl<'a, L: Debug> Debug for RefLockCollection<'a, L> { +impl<L: Debug> Debug for RefLockCollection<'_, L> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct(stringify!(RefLockCollection)) .field("data", self.data) diff --git a/src/lockable.rs b/src/lockable.rs index a2248bc..0066cb4 100644 --- a/src/lockable.rs +++ b/src/lockable.rs @@ -14,7 +14,7 @@ use lock_api::{RawMutex, RawRwLock}; /// A deadlock must never occur. The `unlock` method must correctly unlock the /// data. The `get_ptrs` method must be implemented correctly. The `Output` /// must be unlocked when it is dropped. - +// // Why not use a RawRwLock? Because that would be semantically incorrect, and I // don't want an INIT or GuardMarker associated item. // Originally, RawLock had a sister trait: RawSharableLock. I removed it @@ -262,8 +262,14 @@ unsafe impl<T: Send, R: RawRwLock + Send + Sync> RawLock for RwLock<T, R> { } unsafe impl<T: Send, R: RawMutex + Send + Sync> Lockable for Mutex<T, R> { - type Guard<'g> = MutexRef<'g, T, R> where Self: 'g; - type ReadGuard<'g> = MutexRef<'g, T, R> where Self: 'g; + type Guard<'g> + = MutexRef<'g, T, R> + where + Self: 'g; + type ReadGuard<'g> + = MutexRef<'g, T, R> + where + Self: 'g; fn get_ptrs<'a>(&'a self, ptrs: &mut Vec<&'a dyn RawLock>) { ptrs.push(self); @@ -279,9 +285,15 @@ unsafe impl<T: Send, R: RawMutex + Send + Sync> Lockable for Mutex<T, R> { } unsafe impl<T: Send, R: RawRwLock + Send + Sync> Lockable for RwLock<T, R> { - type Guard<'g> = RwLockWriteRef<'g, T, R> where Self: 'g; + type Guard<'g> + = RwLockWriteRef<'g, T, R> + where + Self: 'g; - type ReadGuard<'g> = RwLockReadRef<'g, T, R> where Self: 'g; + type ReadGuard<'g> + = RwLockReadRef<'g, T, R> + where + Self: 'g; fn get_ptrs<'a>(&'a self, ptrs: &mut Vec<&'a dyn RawLock>) { ptrs.push(self); @@ -305,7 +317,10 @@ impl<T: Send, R: RawMutex + Send + Sync> LockableIntoInner for Mutex<T, R> { } impl<T: Send, R: RawMutex + Send + Sync> LockableAsMut for Mutex<T, R> { - type Inner<'a> = &'a mut T where Self: 'a; + type Inner<'a> + = &'a mut T + where + Self: 'a; fn as_mut(&mut self) -> Self::Inner<'_> { self.get_mut() @@ -321,7 +336,10 @@ impl<T: Send, R: RawRwLock + Send + Sync> LockableIntoInner for RwLock<T, R> { } impl<T: Send, R: RawRwLock + Send + Sync> LockableAsMut for RwLock<T, R> { - type Inner<'a> = &'a mut T where Self: 'a; + type Inner<'a> + = &'a mut T + where + Self: 'a; fn as_mut(&mut self) -> Self::Inner<'_> { AsMut::as_mut(self) @@ -334,10 +352,16 @@ unsafe impl<T: Send, R: RawMutex + Send + Sync> OwnedLockable for Mutex<T, R> {} unsafe impl<T: Send, R: RawRwLock + Send + Sync> OwnedLockable for RwLock<T, R> {} -unsafe impl<'l, T: Send, R: RawRwLock + Send + Sync> Lockable for ReadLock<'l, T, R> { - type Guard<'g> = RwLockReadRef<'g, T, R> where Self: 'g; +unsafe impl<T: Send, R: RawRwLock + Send + Sync> Lockable for ReadLock<'_, T, R> { + type Guard<'g> + = RwLockReadRef<'g, T, R> + where + Self: 'g; - type ReadGuard<'g> = RwLockReadRef<'g, T, R> where Self: 'g; + type ReadGuard<'g> + = RwLockReadRef<'g, T, R> + where + Self: 'g; fn get_ptrs<'a>(&'a self, ptrs: &mut Vec<&'a dyn RawLock>) { ptrs.push(self.as_ref()); @@ -352,10 +376,16 @@ unsafe impl<'l, T: Send, R: RawRwLock + Send + Sync> Lockable for ReadLock<'l, T } } -unsafe impl<'l, T: Send, R: RawRwLock + Send + Sync> Lockable for WriteLock<'l, T, R> { - type Guard<'g> = RwLockWriteRef<'g, T, R> where Self: 'g; +unsafe impl<T: Send, R: RawRwLock + Send + Sync> Lockable for WriteLock<'_, T, R> { + type Guard<'g> + = RwLockWriteRef<'g, T, R> + where + Self: 'g; - type ReadGuard<'g> = RwLockWriteRef<'g, T, R> where Self: 'g; + type ReadGuard<'g> + = RwLockWriteRef<'g, T, R> + where + Self: 'g; fn get_ptrs<'a>(&'a self, ptrs: &mut Vec<&'a dyn RawLock>) { ptrs.push(self.as_ref()); @@ -372,15 +402,21 @@ unsafe impl<'l, T: Send, R: RawRwLock + Send + Sync> Lockable for WriteLock<'l, // Technically, the exclusive locks can also be shared, but there's currently // no way to express that. I don't think I want to ever express that. -unsafe impl<'l, T: Send, R: RawRwLock + Send + Sync> Sharable for ReadLock<'l, T, R> {} +unsafe impl<T: Send, R: RawRwLock + Send + Sync> Sharable for ReadLock<'_, T, R> {} // Because both ReadLock and WriteLock hold references to RwLocks, they can't // implement OwnedLockable unsafe impl<T: Lockable> Lockable for &T { - type Guard<'g> = T::Guard<'g> where Self: 'g; + type Guard<'g> + = T::Guard<'g> + where + Self: 'g; - type ReadGuard<'g> = T::ReadGuard<'g> where Self: 'g; + type ReadGuard<'g> + = T::ReadGuard<'g> + where + Self: 'g; fn get_ptrs<'a>(&'a self, ptrs: &mut Vec<&'a dyn RawLock>) { (*self).get_ptrs(ptrs); @@ -398,9 +434,15 @@ unsafe impl<T: Lockable> Lockable for &T { unsafe impl<T: Sharable> Sharable for &T {} unsafe impl<T: Lockable> Lockable for &mut T { - type Guard<'g> = T::Guard<'g> where Self: 'g; + type Guard<'g> + = T::Guard<'g> + where + Self: 'g; - type ReadGuard<'g> = T::ReadGuard<'g> where Self: 'g; + type ReadGuard<'g> + = T::ReadGuard<'g> + where + Self: 'g; fn get_ptrs<'a>(&'a self, ptrs: &mut Vec<&'a dyn RawLock>) { (**self).get_ptrs(ptrs) @@ -416,7 +458,10 @@ unsafe impl<T: Lockable> Lockable for &mut T { } impl<T: LockableAsMut> LockableAsMut for &mut T { - type Inner<'a> = T::Inner<'a> where Self: 'a; + type Inner<'a> + = T::Inner<'a> + where + Self: 'a; fn as_mut(&mut self) -> Self::Inner<'_> { (*self).as_mut() @@ -482,9 +527,15 @@ tuple_impls!(A B C D E F, 0 1 2 3 4 5); tuple_impls!(A B C D E F G, 0 1 2 3 4 5 6); unsafe impl<T: Lockable, const N: usize> Lockable for [T; N] { - type Guard<'g> = [T::Guard<'g>; N] where Self: 'g; + type Guard<'g> + = [T::Guard<'g>; N] + where + Self: 'g; - type ReadGuard<'g> = [T::ReadGuard<'g>; N] where Self: 'g; + type ReadGuard<'g> + = [T::ReadGuard<'g>; N] + where + Self: 'g; fn get_ptrs<'a>(&'a self, ptrs: &mut Vec<&'a dyn RawLock>) { for lock in self { @@ -514,9 +565,15 @@ unsafe impl<T: Lockable, const N: usize> Lockable for [T; N] { } unsafe impl<T: Lockable> Lockable for Box<[T]> { - type Guard<'g> = Box<[T::Guard<'g>]> where Self: 'g; + type Guard<'g> + = Box<[T::Guard<'g>]> + where + Self: 'g; - type ReadGuard<'g> = Box<[T::ReadGuard<'g>]> where Self: 'g; + type ReadGuard<'g> + = Box<[T::ReadGuard<'g>]> + where + Self: 'g; fn get_ptrs<'a>(&'a self, ptrs: &mut Vec<&'a dyn RawLock>) { for lock in self.iter() { @@ -535,9 +592,15 @@ unsafe impl<T: Lockable> Lockable for Box<[T]> { unsafe impl<T: Lockable> Lockable for Vec<T> { // There's no reason why I'd ever want to extend a list of lock guards - type Guard<'g> = Box<[T::Guard<'g>]> where Self: 'g; + type Guard<'g> + = Box<[T::Guard<'g>]> + where + Self: 'g; - type ReadGuard<'g> = Box<[T::ReadGuard<'g>]> where Self: 'g; + type ReadGuard<'g> + = Box<[T::ReadGuard<'g>]> + where + Self: 'g; fn get_ptrs<'a>(&'a self, ptrs: &mut Vec<&'a dyn RawLock>) { for lock in self { @@ -558,7 +621,10 @@ unsafe impl<T: Lockable> Lockable for Vec<T> { // but I think that'd require sealing up this trait impl<T: LockableAsMut, const N: usize> LockableAsMut for [T; N] { - type Inner<'a> = [T::Inner<'a>; N] where Self: 'a; + type Inner<'a> + = [T::Inner<'a>; N] + where + Self: 'a; fn as_mut(&mut self) -> Self::Inner<'_> { unsafe { @@ -588,7 +654,10 @@ impl<T: LockableIntoInner, const N: usize> LockableIntoInner for [T; N] { } impl<T: LockableAsMut + 'static> LockableAsMut for Box<[T]> { - type Inner<'a> = Box<[T::Inner<'a>]> where Self: 'a; + type Inner<'a> + = Box<[T::Inner<'a>]> + where + Self: 'a; fn as_mut(&mut self) -> Self::Inner<'_> { self.iter_mut().map(LockableAsMut::as_mut).collect() @@ -598,7 +667,10 @@ impl<T: LockableAsMut + 'static> LockableAsMut for Box<[T]> { // TODO: using edition 2024, impl LockableIntoInner for Box<[T]> impl<T: LockableAsMut + 'static> LockableAsMut for Vec<T> { - type Inner<'a> = Box<[T::Inner<'a>]> where Self: 'a; + type Inner<'a> + = Box<[T::Inner<'a>]> + where + Self: 'a; fn as_mut(&mut self) -> Self::Inner<'_> { self.iter_mut().map(LockableAsMut::as_mut).collect() diff --git a/src/mutex.rs b/src/mutex.rs index ae5efc8..51089c4 100644 --- a/src/mutex.rs +++ b/src/mutex.rs @@ -148,7 +148,7 @@ pub struct MutexRef<'a, T: ?Sized + 'a, R: RawMutex>( /// /// [`lock`]: `Mutex::lock` /// [`try_lock`]: `Mutex::try_lock` - +// // This is the most lifetime-intensive thing I've ever written. Can I graduate // from borrow checker university now? pub struct MutexGuard<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable + 'key, R: RawMutex> { diff --git a/src/mutex/guard.rs b/src/mutex/guard.rs index f9324ad..8b2b1aa 100644 --- a/src/mutex/guard.rs +++ b/src/mutex/guard.rs @@ -65,11 +65,8 @@ impl<'a, T: ?Sized + 'a, R: RawMutex> AsMut<T> for MutexRef<'a, T, R> { impl<'a, T: ?Sized + 'a, R: RawMutex> MutexRef<'a, T, R> { /// Creates a reference to the underlying data of a mutex without - /// attempting to lock it or take ownership of the key. - - // This might be useful to export, because it makes it easier to express - // the concept of: "Get the data out the mutex but don't lock it or take - // the key". But it's also quite dangerous to drop. + /// attempting to lock it or take ownership of the key. But it's also quite + /// dangerous to drop. pub(crate) unsafe fn new(mutex: &'a Mutex<T, R>) -> Self { Self(mutex, PhantomData) } diff --git a/src/mutex/mutex.rs b/src/mutex/mutex.rs index d5f7f3a..9707e2f 100644 --- a/src/mutex/mutex.rs +++ b/src/mutex/mutex.rs @@ -1,5 +1,6 @@ +use std::cell::UnsafeCell; use std::fmt::Debug; -use std::{cell::UnsafeCell, marker::PhantomData}; +use std::marker::PhantomData; use lock_api::RawMutex; @@ -66,7 +67,7 @@ impl<T: ?Sized + Debug, R: RawMutex> Debug for Mutex<T, R> { } } -impl<T: ?Sized + Default, R: RawMutex> Default for Mutex<T, R> { +impl<T: Default, R: RawMutex> Default for Mutex<T, R> { fn default() -> Self { Self::new(T::default()) } @@ -150,7 +151,7 @@ impl<T: ?Sized, R: RawMutex> Mutex<T, R> { /// let key = ThreadKey::get().unwrap(); /// assert_eq!(*mutex.lock(key), 10); /// ``` - pub fn lock<'s, 'k: 's, Key: Keyable>(&'s self, key: Key) -> MutexGuard<'_, 'k, T, Key, R> { + pub fn lock<'s, 'k: 's, Key: Keyable>(&'s self, key: Key) -> MutexGuard<'s, 'k, T, Key, R> { unsafe { self.raw.lock(); @@ -190,7 +191,7 @@ impl<T: ?Sized, R: RawMutex> Mutex<T, R> { pub fn try_lock<'s, 'a: 's, 'k: 'a, Key: Keyable>( &'s self, key: Key, - ) -> Option<MutexGuard<'_, 'k, T, Key, R>> { + ) -> Option<MutexGuard<'s, 'k, T, Key, R>> { if self.raw.try_lock() { // safety: we just locked the mutex Some(unsafe { MutexGuard::new(self, key) }) diff --git a/src/poisonable/error.rs b/src/poisonable/error.rs index 61f0f94..9e84693 100644 --- a/src/poisonable/error.rs +++ b/src/poisonable/error.rs @@ -141,7 +141,7 @@ impl<T, Guard: DerefMut<Target = T>> PoisonError<Guard> { } } -impl<'flag, 'key, G, Key> fmt::Debug for TryLockPoisonableError<'flag, 'key, G, Key> { +impl<G, Key> fmt::Debug for TryLockPoisonableError<'_, '_, G, Key> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Self::Poisoned(..) => "Poisoned(..)".fmt(f), @@ -150,7 +150,7 @@ impl<'flag, 'key, G, Key> fmt::Debug for TryLockPoisonableError<'flag, 'key, G, } } -impl<'flag, 'key, G, Key> fmt::Display for TryLockPoisonableError<'flag, 'key, G, Key> { +impl<G, Key> fmt::Display for TryLockPoisonableError<'_, '_, G, Key> { #[cfg_attr(test, mutants::skip)] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { @@ -161,7 +161,7 @@ impl<'flag, 'key, G, Key> fmt::Display for TryLockPoisonableError<'flag, 'key, G } } -impl<'flag, 'key, G, Key> Error for TryLockPoisonableError<'flag, 'key, G, Key> {} +impl<G, Key> Error for TryLockPoisonableError<'_, '_, G, Key> {} impl<'flag, 'key, G, Key> From<PoisonError<PoisonGuard<'flag, 'key, G, Key>>> for TryLockPoisonableError<'flag, 'key, G, Key> diff --git a/src/poisonable/guard.rs b/src/poisonable/guard.rs index d1913bf..30a9b70 100644 --- a/src/poisonable/guard.rs +++ b/src/poisonable/guard.rs @@ -19,7 +19,7 @@ impl<'a, Guard> PoisonRef<'a, Guard> { } } -impl<'flag, Guard> Drop for PoisonRef<'flag, Guard> { +impl<Guard> Drop for PoisonRef<'_, Guard> { fn drop(&mut self) { #[cfg(panic = "unwind")] if std::thread::panicking() { @@ -28,19 +28,19 @@ impl<'flag, Guard> Drop for PoisonRef<'flag, Guard> { } } -impl<'flag, Guard: Debug> Debug for PoisonRef<'flag, Guard> { +impl<Guard: Debug> Debug for PoisonRef<'_, Guard> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(&**self, f) } } -impl<'flag, Guard: Display> Display for PoisonRef<'flag, Guard> { +impl<Guard: Display> Display for PoisonRef<'_, Guard> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&**self, f) } } -impl<'flag, Guard> Deref for PoisonRef<'flag, Guard> { +impl<Guard> Deref for PoisonRef<'_, Guard> { type Target = Guard; fn deref(&self) -> &Self::Target { @@ -48,39 +48,37 @@ impl<'flag, Guard> Deref for PoisonRef<'flag, Guard> { } } -impl<'flag, Guard> DerefMut for PoisonRef<'flag, Guard> { +impl<Guard> DerefMut for PoisonRef<'_, Guard> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.guard } } -impl<'flag, Guard> AsRef<Guard> for PoisonRef<'flag, Guard> { +impl<Guard> AsRef<Guard> for PoisonRef<'_, Guard> { fn as_ref(&self) -> &Guard { &self.guard } } -impl<'flag, Guard> AsMut<Guard> for PoisonRef<'flag, Guard> { +impl<Guard> AsMut<Guard> for PoisonRef<'_, Guard> { fn as_mut(&mut self) -> &mut Guard { &mut self.guard } } -impl<'flag, 'key, Guard: Debug, Key: Keyable> Debug for PoisonGuard<'flag, 'key, Guard, Key> { +impl<Guard: Debug, Key: Keyable> Debug for PoisonGuard<'_, '_, Guard, Key> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(&self.guard, f) } } -impl<'flag, 'key, Guard: Display, Key: Keyable> Display for PoisonGuard<'flag, 'key, Guard, Key> { +impl<Guard: Display, Key: Keyable> Display for PoisonGuard<'_, '_, Guard, Key> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&self.guard, f) } } -impl<'flag, 'key, T, Guard: Deref<Target = T>, Key: Keyable> Deref - for PoisonGuard<'flag, 'key, Guard, Key> -{ +impl<T, Guard: Deref<Target = T>, Key: Keyable> Deref for PoisonGuard<'_, '_, Guard, Key> { type Target = T; fn deref(&self) -> &Self::Target { @@ -89,22 +87,20 @@ impl<'flag, 'key, T, Guard: Deref<Target = T>, Key: Keyable> Deref } } -impl<'flag, 'key, T, Guard: DerefMut<Target = T>, Key: Keyable> DerefMut - for PoisonGuard<'flag, 'key, Guard, Key> -{ +impl<T, Guard: DerefMut<Target = T>, Key: Keyable> DerefMut for PoisonGuard<'_, '_, Guard, Key> { fn deref_mut(&mut self) -> &mut Self::Target { #[allow(clippy::explicit_auto_deref)] // fixing this results in a compiler error &mut *self.guard.guard } } -impl<'flag, 'key, Guard, Key: Keyable> AsRef<Guard> for PoisonGuard<'flag, 'key, Guard, Key> { +impl<Guard, Key: Keyable> AsRef<Guard> for PoisonGuard<'_, '_, Guard, Key> { fn as_ref(&self) -> &Guard { &self.guard.guard } } -impl<'flag, 'key, Guard, Key: Keyable> AsMut<Guard> for PoisonGuard<'flag, 'key, Guard, Key> { +impl<Guard, Key: Keyable> AsMut<Guard> for PoisonGuard<'_, '_, Guard, Key> { fn as_mut(&mut self) -> &mut Guard { &mut self.guard.guard } diff --git a/src/rwlock/read_lock.rs b/src/rwlock/read_lock.rs index 4f2bc86..c5c4c8c 100644 --- a/src/rwlock/read_lock.rs +++ b/src/rwlock/read_lock.rs @@ -6,7 +6,7 @@ use crate::key::Keyable; use super::{ReadLock, RwLock, RwLockReadGuard, RwLockReadRef}; -impl<'l, T: ?Sized + Debug, R: RawRwLock> Debug for ReadLock<'l, T, R> { +impl<T: ?Sized + Debug, R: RawRwLock> Debug for ReadLock<'_, T, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { // safety: this is just a try lock, and the value is dropped // immediately after, so there's no risk of blocking ourselves @@ -34,7 +34,7 @@ impl<'l, T, R> From<&'l RwLock<T, R>> for ReadLock<'l, T, R> { } } -impl<'l, T: ?Sized, R> AsRef<RwLock<T, R>> for ReadLock<'l, T, R> { +impl<T: ?Sized, R> AsRef<RwLock<T, R>> for ReadLock<'_, T, R> { fn as_ref(&self) -> &RwLock<T, R> { self.0 } @@ -57,13 +57,13 @@ impl<'l, T, R> ReadLock<'l, T, R> { } } -impl<'l, T: ?Sized, R: RawRwLock> ReadLock<'l, T, R> { +impl<T: ?Sized, R: RawRwLock> ReadLock<'_, T, R> { /// Locks the underlying [`RwLock`] with shared read access, blocking the /// current thread until it can be acquired. pub fn lock<'s, 'key: 's, Key: Keyable + 'key>( &'s self, key: Key, - ) -> RwLockReadGuard<'_, 'key, T, Key, R> { + ) -> RwLockReadGuard<'s, 'key, T, Key, R> { self.0.read(key) } @@ -72,7 +72,7 @@ impl<'l, T: ?Sized, R: RawRwLock> ReadLock<'l, T, R> { pub fn try_lock<'s, 'key: 's, Key: Keyable + 'key>( &'s self, key: Key, - ) -> Option<RwLockReadGuard<'_, 'key, T, Key, R>> { + ) -> Option<RwLockReadGuard<'s, 'key, T, Key, R>> { self.0.try_read(key) } diff --git a/src/rwlock/rwlock.rs b/src/rwlock/rwlock.rs index fddcf5a..063ab68 100644 --- a/src/rwlock/rwlock.rs +++ b/src/rwlock/rwlock.rs @@ -62,7 +62,7 @@ impl<T: ?Sized + Debug, R: RawRwLock> Debug for RwLock<T, R> { } } -impl<T: ?Sized + Default, R: RawRwLock> Default for RwLock<T, R> { +impl<T: Default, R: RawRwLock> Default for RwLock<T, R> { fn default() -> Self { Self::new(T::default()) } @@ -140,7 +140,7 @@ impl<T: ?Sized, R: RawRwLock> RwLock<T, R> { pub fn read<'s, 'key: 's, Key: Keyable>( &'s self, key: Key, - ) -> RwLockReadGuard<'_, 'key, T, Key, R> { + ) -> RwLockReadGuard<'s, 'key, T, Key, R> { unsafe { self.raw.lock_shared(); @@ -172,7 +172,7 @@ impl<T: ?Sized, R: RawRwLock> RwLock<T, R> { pub fn try_read<'s, 'key: 's, Key: Keyable>( &'s self, key: Key, - ) -> Option<RwLockReadGuard<'_, 'key, T, Key, R>> { + ) -> Option<RwLockReadGuard<'s, 'key, T, Key, R>> { unsafe { if self.raw.try_lock_shared() { // safety: the lock is locked first @@ -233,7 +233,7 @@ impl<T: ?Sized, R: RawRwLock> RwLock<T, R> { pub fn write<'s, 'key: 's, Key: Keyable>( &'s self, key: Key, - ) -> RwLockWriteGuard<'_, 'key, T, Key, R> { + ) -> RwLockWriteGuard<'s, 'key, T, Key, R> { unsafe { self.raw.lock_exclusive(); @@ -266,7 +266,7 @@ impl<T: ?Sized, R: RawRwLock> RwLock<T, R> { pub fn try_write<'s, 'key: 's, Key: Keyable>( &'s self, key: Key, - ) -> Option<RwLockWriteGuard<'_, 'key, T, Key, R>> { + ) -> Option<RwLockWriteGuard<'s, 'key, T, Key, R>> { unsafe { if self.raw.try_lock_exclusive() { // safety: the lock is locked first diff --git a/src/rwlock/write_lock.rs b/src/rwlock/write_lock.rs index 15eaacc..77b68c8 100644 --- a/src/rwlock/write_lock.rs +++ b/src/rwlock/write_lock.rs @@ -6,7 +6,7 @@ use crate::key::Keyable; use super::{RwLock, RwLockWriteGuard, WriteLock}; -impl<'l, T: ?Sized + Debug, R: RawRwLock> Debug for WriteLock<'l, T, R> { +impl<T: ?Sized + Debug, R: RawRwLock> Debug for WriteLock<'_, T, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { // safety: this is just a try lock, and the value is dropped // immediately after, so there's no risk of blocking ourselves @@ -36,7 +36,7 @@ impl<'l, T, R> From<&'l RwLock<T, R>> for WriteLock<'l, T, R> { } } -impl<'l, T: ?Sized, R> AsRef<RwLock<T, R>> for WriteLock<'l, T, R> { +impl<T: ?Sized, R> AsRef<RwLock<T, R>> for WriteLock<'_, T, R> { fn as_ref(&self) -> &RwLock<T, R> { self.0 } @@ -59,13 +59,13 @@ impl<'l, T, R> WriteLock<'l, T, R> { } } -impl<'l, T: ?Sized, R: RawRwLock> WriteLock<'l, T, R> { +impl<T: ?Sized, R: RawRwLock> WriteLock<'_, T, R> { /// Locks the underlying [`RwLock`] with exclusive write access, blocking /// the current until it can be acquired. pub fn lock<'s, 'key: 's, Key: Keyable + 'key>( &'s self, key: Key, - ) -> RwLockWriteGuard<'_, 'key, T, Key, R> { + ) -> RwLockWriteGuard<'s, 'key, T, Key, R> { self.0.write(key) } @@ -73,7 +73,7 @@ impl<'l, T: ?Sized, R: RawRwLock> WriteLock<'l, T, R> { pub fn try_lock<'s, 'key: 's, Key: Keyable + 'key>( &'s self, key: Key, - ) -> Option<RwLockWriteGuard<'_, 'key, T, Key, R>> { + ) -> Option<RwLockWriteGuard<'s, 'key, T, Key, R>> { self.0.try_write(key) } |
