From 4ba03be97e6cc7e790bbc9bfc18caaa228c8a262 Mon Sep 17 00:00:00 2001 From: Botahamec Date: Fri, 28 Feb 2025 16:09:11 -0500 Subject: Scoped lock API --- src/poisonable/guard.rs | 64 ++++++------------------------------------------- 1 file changed, 7 insertions(+), 57 deletions(-) (limited to 'src/poisonable/guard.rs') diff --git a/src/poisonable/guard.rs b/src/poisonable/guard.rs index 3f85d25..b887e2d 100644 --- a/src/poisonable/guard.rs +++ b/src/poisonable/guard.rs @@ -3,8 +3,6 @@ use std::hash::Hash; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; -use crate::Keyable; - use super::{PoisonFlag, PoisonGuard, PoisonRef}; impl<'a, Guard> PoisonRef<'a, Guard> { @@ -28,26 +26,6 @@ impl Drop for PoisonRef<'_, Guard> { } } -impl PartialEq for PoisonRef<'_, Guard> { - fn eq(&self, other: &Self) -> bool { - self.guard.eq(&other.guard) - } -} - -impl PartialOrd for PoisonRef<'_, Guard> { - fn partial_cmp(&self, other: &Self) -> Option { - self.guard.partial_cmp(&other.guard) - } -} - -impl Eq for PoisonRef<'_, Guard> {} - -impl Ord for PoisonRef<'_, Guard> { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.guard.cmp(&other.guard) - } -} - #[mutants::skip] // hashing involves RNG and is hard to test #[cfg(not(tarpaulin_include))] impl Hash for PoisonRef<'_, Guard> { @@ -96,37 +74,9 @@ impl AsMut for PoisonRef<'_, Guard> { } } -#[mutants::skip] // it's hard to get two guards safely -#[cfg(not(tarpaulin_include))] -impl PartialEq for PoisonGuard<'_, '_, Guard, Key> { - fn eq(&self, other: &Self) -> bool { - self.guard.eq(&other.guard) - } -} - -#[mutants::skip] // it's hard to get two guards safely -#[cfg(not(tarpaulin_include))] -impl PartialOrd for PoisonGuard<'_, '_, Guard, Key> { - fn partial_cmp(&self, other: &Self) -> Option { - self.guard.partial_cmp(&other.guard) - } -} - -#[mutants::skip] // it's hard to get two guards safely -#[cfg(not(tarpaulin_include))] -impl Eq for PoisonGuard<'_, '_, Guard, Key> {} - -#[mutants::skip] // it's hard to get two guards safely -#[cfg(not(tarpaulin_include))] -impl Ord for PoisonGuard<'_, '_, Guard, Key> { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.guard.cmp(&other.guard) - } -} - #[mutants::skip] // hashing involves RNG and is hard to test #[cfg(not(tarpaulin_include))] -impl Hash for PoisonGuard<'_, '_, Guard, Key> { +impl Hash for PoisonGuard<'_, Guard> { fn hash(&self, state: &mut H) { self.guard.hash(state) } @@ -134,19 +84,19 @@ impl Hash for PoisonGuard<'_, '_, Guard, Key> { #[mutants::skip] #[cfg(not(tarpaulin_include))] -impl Debug for PoisonGuard<'_, '_, Guard, Key> { +impl Debug for PoisonGuard<'_, Guard> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(&self.guard, f) } } -impl Display for PoisonGuard<'_, '_, Guard, Key> { +impl Display for PoisonGuard<'_, Guard> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&self.guard, f) } } -impl, Key: Keyable> Deref for PoisonGuard<'_, '_, Guard, Key> { +impl> Deref for PoisonGuard<'_, Guard> { type Target = T; fn deref(&self) -> &Self::Target { @@ -155,20 +105,20 @@ impl, Key: Keyable> Deref for PoisonGuard<'_, '_, Gu } } -impl, Key: Keyable> DerefMut for PoisonGuard<'_, '_, Guard, Key> { +impl> DerefMut for PoisonGuard<'_, Guard> { 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 AsRef for PoisonGuard<'_, '_, Guard, Key> { +impl AsRef for PoisonGuard<'_, Guard> { fn as_ref(&self) -> &Guard { &self.guard.guard } } -impl AsMut for PoisonGuard<'_, '_, Guard, Key> { +impl AsMut for PoisonGuard<'_, Guard> { fn as_mut(&mut self) -> &mut Guard { &mut self.guard.guard } -- cgit v1.2.3