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/mutex/guard.rs | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'src/mutex/guard.rs') diff --git a/src/mutex/guard.rs b/src/mutex/guard.rs index b79d90b..e661230 100644 --- a/src/mutex/guard.rs +++ b/src/mutex/guard.rs @@ -38,19 +38,19 @@ impl Hash for MutexRef<'_, T, R> { // This makes things slightly easier because now you can use // `println!("{guard}")` instead of `println!("{}", *guard)` -impl<'a, T: Debug + ?Sized + 'a, R: RawMutex> Debug for MutexRef<'a, T, R> { +impl Debug for MutexRef<'_, T, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(&**self, f) } } -impl<'a, T: Display + ?Sized + 'a, R: RawMutex> Display for MutexRef<'a, T, R> { +impl Display for MutexRef<'_, T, R> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&**self, f) } } -impl<'a, T: ?Sized + 'a, R: RawMutex> Drop for MutexRef<'a, T, R> { +impl Drop for MutexRef<'_, T, R> { fn drop(&mut self) { // safety: this guard is being destroyed, so the data cannot be // accessed without locking again @@ -58,7 +58,7 @@ impl<'a, T: ?Sized + 'a, R: RawMutex> Drop for MutexRef<'a, T, R> { } } -impl<'a, T: ?Sized + 'a, R: RawMutex> Deref for MutexRef<'a, T, R> { +impl Deref for MutexRef<'_, T, R> { type Target = T; fn deref(&self) -> &Self::Target { @@ -69,7 +69,7 @@ impl<'a, T: ?Sized + 'a, R: RawMutex> Deref for MutexRef<'a, T, R> { } } -impl<'a, T: ?Sized + 'a, R: RawMutex> DerefMut for MutexRef<'a, T, R> { +impl DerefMut for MutexRef<'_, 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 @@ -78,19 +78,19 @@ impl<'a, T: ?Sized + 'a, R: RawMutex> DerefMut for MutexRef<'a, T, R> { } } -impl<'a, T: ?Sized + 'a, R: RawMutex> AsRef for MutexRef<'a, T, R> { +impl AsRef for MutexRef<'_, T, R> { fn as_ref(&self) -> &T { self } } -impl<'a, T: ?Sized + 'a, R: RawMutex> AsMut for MutexRef<'a, T, R> { +impl AsMut for MutexRef<'_, T, R> { fn as_mut(&mut self) -> &mut T { self } } -impl<'a, T: ?Sized + 'a, R: RawMutex> MutexRef<'a, T, R> { +impl<'a, T: ?Sized, 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. But it's also quite /// dangerous to drop. @@ -130,25 +130,19 @@ impl Hash for MutexGuard<'_, '_, T, } } -impl<'a, 'key, T: Debug + ?Sized + 'a, Key: Keyable + 'key, R: RawMutex> Debug - for MutexGuard<'a, 'key, T, Key, R> -{ +impl Debug for MutexGuard<'_, '_, 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: RawMutex> Display - for MutexGuard<'a, 'key, T, Key, R> -{ +impl Display for MutexGuard<'_, '_, 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: RawMutex> Deref - for MutexGuard<'a, 'key, T, Key, R> -{ +impl Deref for MutexGuard<'_, '_, T, Key, R> { type Target = T; fn deref(&self) -> &Self::Target { @@ -156,31 +150,25 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawMutex> Deref } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawMutex> DerefMut - for MutexGuard<'a, 'key, T, Key, R> -{ +impl DerefMut for MutexGuard<'_, '_, T, Key, R> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.mutex } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawMutex> AsRef - for MutexGuard<'a, 'key, T, Key, R> -{ +impl AsRef for MutexGuard<'_, '_, T, Key, R> { fn as_ref(&self) -> &T { self } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawMutex> AsMut - for MutexGuard<'a, 'key, T, Key, R> -{ +impl AsMut for MutexGuard<'_, '_, T, Key, R> { fn as_mut(&mut self) -> &mut T { self } } -impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawMutex> MutexGuard<'a, 'key, T, Key, R> { +impl<'a, T: ?Sized, Key: Keyable, R: RawMutex> MutexGuard<'a, '_, T, Key, R> { /// Create a guard to the given mutex. Undefined if multiple guards to the /// same mutex exist at once. #[must_use] @@ -193,4 +181,4 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawMutex> MutexGuard<'a, 'ke } } -unsafe impl<'a, T: ?Sized + Sync + 'a, R: RawMutex + Sync + 'a> Sync for MutexRef<'a, T, R> {} +unsafe impl Sync for MutexRef<'_, T, R> {} -- cgit v1.2.3