summaryrefslogtreecommitdiff
path: root/src/rwlock/read_guard.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/rwlock/read_guard.rs')
-rw-r--r--src/rwlock/read_guard.rs71
1 files changed, 8 insertions, 63 deletions
diff --git a/src/rwlock/read_guard.rs b/src/rwlock/read_guard.rs
index bd22837..0d68c75 100644
--- a/src/rwlock/read_guard.rs
+++ b/src/rwlock/read_guard.rs
@@ -5,34 +5,14 @@ use std::ops::Deref;
use lock_api::RawRwLock;
-use crate::key::Keyable;
use crate::lockable::RawLock;
+use crate::ThreadKey;
use super::{RwLock, RwLockReadGuard, RwLockReadRef};
// These impls make things slightly easier because now you can use
// `println!("{guard}")` instead of `println!("{}", *guard)`
-impl<T: PartialEq + ?Sized, R: RawRwLock> PartialEq for RwLockReadRef<'_, T, R> {
- fn eq(&self, other: &Self) -> bool {
- self.deref().eq(&**other)
- }
-}
-
-impl<T: Eq + ?Sized, R: RawRwLock> Eq for RwLockReadRef<'_, T, R> {}
-
-impl<T: PartialOrd + ?Sized, R: RawRwLock> PartialOrd for RwLockReadRef<'_, T, R> {
- fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
- self.deref().partial_cmp(&**other)
- }
-}
-
-impl<T: Ord + ?Sized, R: RawRwLock> Ord for RwLockReadRef<'_, T, R> {
- fn cmp(&self, other: &Self) -> std::cmp::Ordering {
- self.deref().cmp(&**other)
- }
-}
-
#[mutants::skip] // hashing involves PRNG and is hard to test
#[cfg(not(tarpaulin_include))]
impl<T: Hash + ?Sized, R: RawRwLock> Hash for RwLockReadRef<'_, T, R> {
@@ -89,41 +69,9 @@ impl<'a, T: ?Sized, R: RawRwLock> RwLockReadRef<'a, T, R> {
}
}
-#[mutants::skip] // it's hard to get two read guards safely
-#[cfg(not(tarpaulin_include))]
-impl<T: PartialEq + ?Sized, R: RawRwLock, Key: Keyable> PartialEq
- for RwLockReadGuard<'_, '_, T, Key, R>
-{
- fn eq(&self, other: &Self) -> bool {
- self.deref().eq(&**other)
- }
-}
-
-#[mutants::skip] // it's hard to get two read guards safely
-#[cfg(not(tarpaulin_include))]
-impl<T: Eq + ?Sized, R: RawRwLock, Key: Keyable> Eq for RwLockReadGuard<'_, '_, T, Key, R> {}
-
-#[mutants::skip] // it's hard to get two read guards safely
-#[cfg(not(tarpaulin_include))]
-impl<T: PartialOrd + ?Sized, R: RawRwLock, Key: Keyable> PartialOrd
- for RwLockReadGuard<'_, '_, T, Key, R>
-{
- fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
- self.deref().partial_cmp(&**other)
- }
-}
-
-#[mutants::skip] // it's hard to get two read guards safely
-#[cfg(not(tarpaulin_include))]
-impl<T: Ord + ?Sized, R: RawRwLock, Key: Keyable> Ord for RwLockReadGuard<'_, '_, T, Key, R> {
- fn cmp(&self, other: &Self) -> std::cmp::Ordering {
- self.deref().cmp(&**other)
- }
-}
-
#[mutants::skip] // hashing involves PRNG and is hard to test
#[cfg(not(tarpaulin_include))]
-impl<T: Hash + ?Sized, R: RawRwLock, Key: Keyable> Hash for RwLockReadGuard<'_, '_, T, Key, R> {
+impl<T: Hash + ?Sized, R: RawRwLock> Hash for RwLockReadGuard<'_, T, R> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.deref().hash(state)
}
@@ -131,21 +79,19 @@ impl<T: Hash + ?Sized, R: RawRwLock, Key: Keyable> Hash for RwLockReadGuard<'_,
#[mutants::skip]
#[cfg(not(tarpaulin_include))]
-impl<T: Debug + ?Sized, Key: Keyable, R: RawRwLock> Debug for RwLockReadGuard<'_, '_, T, Key, R> {
+impl<T: Debug + ?Sized, R: RawRwLock> Debug for RwLockReadGuard<'_, T, R> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&**self, f)
}
}
-impl<T: Display + ?Sized, Key: Keyable, R: RawRwLock> Display
- for RwLockReadGuard<'_, '_, T, Key, R>
-{
+impl<T: Display + ?Sized, R: RawRwLock> Display for RwLockReadGuard<'_, T, R> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Display::fmt(&**self, f)
}
}
-impl<T: ?Sized, Key: Keyable, R: RawRwLock> Deref for RwLockReadGuard<'_, '_, T, Key, R> {
+impl<T: ?Sized, R: RawRwLock> Deref for RwLockReadGuard<'_, T, R> {
type Target = T;
fn deref(&self) -> &Self::Target {
@@ -153,21 +99,20 @@ impl<T: ?Sized, Key: Keyable, R: RawRwLock> Deref for RwLockReadGuard<'_, '_, T,
}
}
-impl<T: ?Sized, Key: Keyable, R: RawRwLock> AsRef<T> for RwLockReadGuard<'_, '_, T, Key, R> {
+impl<T: ?Sized, R: RawRwLock> AsRef<T> for RwLockReadGuard<'_, T, R> {
fn as_ref(&self) -> &T {
self
}
}
-impl<'a, T: ?Sized, Key: Keyable, R: RawRwLock> RwLockReadGuard<'a, '_, T, Key, R> {
+impl<'a, T: ?Sized, R: RawRwLock> RwLockReadGuard<'a, T, R> {
/// Create a guard to the given mutex. Undefined if multiple guards to the
/// same mutex exist at once.
#[must_use]
- pub(super) unsafe fn new(rwlock: &'a RwLock<T, R>, thread_key: Key) -> Self {
+ pub(super) unsafe fn new(rwlock: &'a RwLock<T, R>, thread_key: ThreadKey) -> Self {
Self {
rwlock: RwLockReadRef(rwlock, PhantomData),
thread_key,
- _phantom: PhantomData,
}
}
}