From a060123077b94f61e3d0802a6977ad547276fd1b Mon Sep 17 00:00:00 2001 From: Mica White Date: Thu, 26 Dec 2024 10:54:51 -0500 Subject: Remove unnecessary generics --- src/rwlock/read_guard.rs | 34 +++++++++++++--------------------- src/rwlock/write_guard.rs | 44 ++++++++++++++++---------------------------- 2 files changed, 29 insertions(+), 49 deletions(-) (limited to 'src/rwlock') diff --git a/src/rwlock/read_guard.rs b/src/rwlock/read_guard.rs index 45d0bd9..44b737e 100644 --- a/src/rwlock/read_guard.rs +++ b/src/rwlock/read_guard.rs @@ -36,19 +36,19 @@ impl Hash for RwLockReadRef<'_, T, R> { } } -impl<'a, T: Debug + ?Sized + 'a, R: RawRwLock> Debug for RwLockReadRef<'a, T, R> { +impl Debug for RwLockReadRef<'_, T, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(&**self, f) } } -impl<'a, T: Display + ?Sized + 'a, R: RawRwLock> Display for RwLockReadRef<'a, T, R> { +impl Display for RwLockReadRef<'_, T, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&**self, f) } } -impl<'a, T: ?Sized + 'a, R: RawRwLock> Deref for RwLockReadRef<'a, T, R> { +impl Deref for RwLockReadRef<'_, T, R> { type Target = T; fn deref(&self) -> &Self::Target { @@ -59,13 +59,13 @@ impl<'a, T: ?Sized + 'a, R: RawRwLock> Deref for RwLockReadRef<'a, T, R> { } } -impl<'a, T: ?Sized + 'a, R: RawRwLock> AsRef for RwLockReadRef<'a, T, R> { +impl AsRef for RwLockReadRef<'_, T, R> { fn as_ref(&self) -> &T { self } } -impl<'a, T: ?Sized + 'a, R: RawRwLock> Drop for RwLockReadRef<'a, T, R> { +impl Drop for RwLockReadRef<'_, T, R> { fn drop(&mut self) { // safety: this guard is being destroyed, so the data cannot be // accessed without locking again @@ -73,7 +73,7 @@ impl<'a, T: ?Sized + 'a, R: RawRwLock> Drop for RwLockReadRef<'a, T, R> { } } -impl<'a, T: ?Sized + 'a, R: RawRwLock> RwLockReadRef<'a, T, R> { +impl<'a, T: ?Sized, R: RawRwLock> RwLockReadRef<'a, T, R> { /// Creates an immutable reference for the underlying data of an [`RwLock`] /// without locking it or taking ownership of the key. #[must_use] @@ -112,25 +112,21 @@ impl Hash for RwLockReadGuard<'_, } } -impl<'a, 'key, T: Debug + ?Sized + 'a, Key: Keyable + 'key, R: RawRwLock> Debug - for RwLockReadGuard<'a, 'key, T, Key, R> -{ +impl Debug for RwLockReadGuard<'_, '_, T, Key, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(&**self, f) } } -impl<'a, 'key, T: Display + ?Sized + 'a, Key: Keyable + 'key, R: RawRwLock> Display - for RwLockReadGuard<'a, 'key, T, Key, R> +impl Display + for RwLockReadGuard<'_, '_, T, Key, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&**self, f) } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> Deref - for RwLockReadGuard<'a, 'key, T, Key, R> -{ +impl Deref for RwLockReadGuard<'_, '_, T, Key, R> { type Target = T; fn deref(&self) -> &Self::Target { @@ -138,17 +134,13 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> Deref } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> AsRef - for RwLockReadGuard<'a, 'key, T, Key, R> -{ +impl AsRef for RwLockReadGuard<'_, '_, T, Key, R> { fn as_ref(&self) -> &T { self } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> - RwLockReadGuard<'a, 'key, T, Key, R> -{ +impl<'a, T: ?Sized, Key: Keyable, R: RawRwLock> RwLockReadGuard<'a, '_, T, Key, R> { /// Create a guard to the given mutex. Undefined if multiple guards to the /// same mutex exist at once. #[must_use] @@ -161,4 +153,4 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> } } -unsafe impl<'a, T: ?Sized + Sync + 'a, R: RawRwLock + Sync + 'a> Sync for RwLockReadRef<'a, T, R> {} +unsafe impl Sync for RwLockReadRef<'_, T, R> {} diff --git a/src/rwlock/write_guard.rs b/src/rwlock/write_guard.rs index 62f7762..c22ebe1 100644 --- a/src/rwlock/write_guard.rs +++ b/src/rwlock/write_guard.rs @@ -36,19 +36,19 @@ impl Hash for RwLockWriteRef<'_, T, R> { } } -impl<'a, T: Debug + ?Sized + 'a, R: RawRwLock> Debug for RwLockWriteRef<'a, T, R> { +impl Debug for RwLockWriteRef<'_, T, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(&**self, f) } } -impl<'a, T: Display + ?Sized + 'a, R: RawRwLock> Display for RwLockWriteRef<'a, T, R> { +impl Display for RwLockWriteRef<'_, T, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&**self, f) } } -impl<'a, T: ?Sized + 'a, R: RawRwLock> Deref for RwLockWriteRef<'a, T, R> { +impl Deref for RwLockWriteRef<'_, T, R> { type Target = T; fn deref(&self) -> &Self::Target { @@ -59,7 +59,7 @@ impl<'a, T: ?Sized + 'a, R: RawRwLock> Deref for RwLockWriteRef<'a, T, R> { } } -impl<'a, T: ?Sized + 'a, R: RawRwLock> DerefMut for RwLockWriteRef<'a, T, R> { +impl DerefMut for RwLockWriteRef<'_, T, R> { fn deref_mut(&mut self) -> &mut Self::Target { // safety: this is the only type that can use `value`, and we have a // mutable reference to this type, so there cannot be any other @@ -68,19 +68,19 @@ impl<'a, T: ?Sized + 'a, R: RawRwLock> DerefMut for RwLockWriteRef<'a, T, R> { } } -impl<'a, T: ?Sized + 'a, R: RawRwLock> AsRef for RwLockWriteRef<'a, T, R> { +impl AsRef for RwLockWriteRef<'_, T, R> { fn as_ref(&self) -> &T { self } } -impl<'a, T: ?Sized + 'a, R: RawRwLock> AsMut for RwLockWriteRef<'a, T, R> { +impl AsMut for RwLockWriteRef<'_, T, R> { fn as_mut(&mut self) -> &mut T { self } } -impl<'a, T: ?Sized + 'a, R: RawRwLock> Drop for RwLockWriteRef<'a, T, R> { +impl Drop for RwLockWriteRef<'_, T, R> { fn drop(&mut self) { // safety: this guard is being destroyed, so the data cannot be // accessed without locking again @@ -127,25 +127,21 @@ impl Hash for RwLockWriteGuard<'_, } } -impl<'a, 'key, T: Debug + ?Sized + 'a, Key: Keyable + 'key, R: RawRwLock> Debug - for RwLockWriteGuard<'a, 'key, T, Key, R> -{ +impl Debug for RwLockWriteGuard<'_, '_, T, Key, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(&**self, f) } } -impl<'a, 'key, T: Display + ?Sized + 'a, Key: Keyable + 'key, R: RawRwLock> Display - for RwLockWriteGuard<'a, 'key, T, Key, R> +impl Display + for RwLockWriteGuard<'_, '_, T, Key, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&**self, f) } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> Deref - for RwLockWriteGuard<'a, 'key, T, Key, R> -{ +impl Deref for RwLockWriteGuard<'_, '_, T, Key, R> { type Target = T; fn deref(&self) -> &Self::Target { @@ -153,33 +149,25 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> Deref } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> DerefMut - for RwLockWriteGuard<'a, 'key, T, Key, R> -{ +impl DerefMut for RwLockWriteGuard<'_, '_, T, Key, R> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.rwlock } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> AsRef - for RwLockWriteGuard<'a, 'key, T, Key, R> -{ +impl AsRef for RwLockWriteGuard<'_, '_, T, Key, R> { fn as_ref(&self) -> &T { self } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> AsMut - for RwLockWriteGuard<'a, 'key, T, Key, R> -{ +impl AsMut for RwLockWriteGuard<'_, '_, T, Key, R> { fn as_mut(&mut self) -> &mut T { self } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> - RwLockWriteGuard<'a, 'key, T, Key, R> -{ +impl<'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> RwLockWriteGuard<'a, '_, T, Key, R> { /// Create a guard to the given mutex. Undefined if multiple guards to the /// same mutex exist at once. #[must_use] @@ -192,4 +180,4 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> } } -unsafe impl<'a, T: ?Sized + Sync + 'a, R: RawRwLock + Sync + 'a> Sync for RwLockWriteRef<'a, T, R> {} +unsafe impl Sync for RwLockWriteRef<'_, T, R> {} -- cgit v1.2.3