summaryrefslogtreecommitdiff
path: root/src/poisonable
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2025-02-05 20:31:00 -0500
committerBotahamec <botahamec@outlook.com>2025-02-05 20:31:00 -0500
commitf6b38f7425a3183214dae79445446b042154688f (patch)
tree1219d7cc4420ff4ad58a017c0f5861b7a2936f3b /src/poisonable
parent280a61ad7b74019c7aad8b7306a0dd7cfb11359c (diff)
Tests and optimization
Diffstat (limited to 'src/poisonable')
-rw-r--r--src/poisonable/error.rs4
-rw-r--r--src/poisonable/flag.rs1
-rw-r--r--src/poisonable/guard.rs8
-rw-r--r--src/poisonable/poisonable.rs1
4 files changed, 14 insertions, 0 deletions
diff --git a/src/poisonable/error.rs b/src/poisonable/error.rs
index 9721ce4..bff011d 100644
--- a/src/poisonable/error.rs
+++ b/src/poisonable/error.rs
@@ -4,6 +4,7 @@ use std::error::Error;
use super::{PoisonError, PoisonGuard, TryLockPoisonableError};
#[mutants::skip]
+#[cfg(not(tarpaulin_include))]
impl<Guard> fmt::Debug for PoisonError<Guard> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("PoisonError").finish_non_exhaustive()
@@ -12,6 +13,7 @@ impl<Guard> fmt::Debug for PoisonError<Guard> {
impl<Guard> fmt::Display for PoisonError<Guard> {
#[cfg_attr(test, mutants::skip)]
+ #[cfg(not(tarpaulin_include))]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
"poisoned lock: another task failed inside".fmt(f)
}
@@ -151,6 +153,7 @@ impl<Guard> PoisonError<Guard> {
}
#[mutants::skip]
+#[cfg(not(tarpaulin_include))]
impl<G, Key> fmt::Debug for TryLockPoisonableError<'_, '_, G, Key> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
@@ -162,6 +165,7 @@ impl<G, Key> fmt::Debug for TryLockPoisonableError<'_, '_, G, Key> {
impl<G, Key> fmt::Display for TryLockPoisonableError<'_, '_, G, Key> {
#[cfg_attr(test, mutants::skip)]
+ #[cfg(not(tarpaulin_include))]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Self::Poisoned(..) => "poisoned lock: another task failed inside",
diff --git a/src/poisonable/flag.rs b/src/poisonable/flag.rs
index 6b567c8..9186bbc 100644
--- a/src/poisonable/flag.rs
+++ b/src/poisonable/flag.rs
@@ -29,6 +29,7 @@ impl PoisonFlag {
}
#[mutants::skip] // None of the tests have panic = "abort", so this can't be tested
+ #[cfg(not(tarpaulin_include))]
pub fn is_poisoned(&self) -> bool {
false
}
diff --git a/src/poisonable/guard.rs b/src/poisonable/guard.rs
index 36566f5..3f85d25 100644
--- a/src/poisonable/guard.rs
+++ b/src/poisonable/guard.rs
@@ -49,6 +49,7 @@ impl<Guard: Ord> Ord for PoisonRef<'_, Guard> {
}
#[mutants::skip] // hashing involves RNG and is hard to test
+#[cfg(not(tarpaulin_include))]
impl<Guard: Hash> Hash for PoisonRef<'_, Guard> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.guard.hash(state)
@@ -56,6 +57,7 @@ impl<Guard: Hash> Hash for PoisonRef<'_, Guard> {
}
#[mutants::skip]
+#[cfg(not(tarpaulin_include))]
impl<Guard: Debug> Debug for PoisonRef<'_, Guard> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&**self, f)
@@ -95,6 +97,7 @@ impl<Guard> AsMut<Guard> for PoisonRef<'_, Guard> {
}
#[mutants::skip] // it's hard to get two guards safely
+#[cfg(not(tarpaulin_include))]
impl<Guard: PartialEq, Key: Keyable> PartialEq for PoisonGuard<'_, '_, Guard, Key> {
fn eq(&self, other: &Self) -> bool {
self.guard.eq(&other.guard)
@@ -102,6 +105,7 @@ impl<Guard: PartialEq, Key: Keyable> PartialEq for PoisonGuard<'_, '_, Guard, Ke
}
#[mutants::skip] // it's hard to get two guards safely
+#[cfg(not(tarpaulin_include))]
impl<Guard: PartialOrd, Key: Keyable> PartialOrd for PoisonGuard<'_, '_, Guard, Key> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.guard.partial_cmp(&other.guard)
@@ -109,9 +113,11 @@ impl<Guard: PartialOrd, Key: Keyable> PartialOrd for PoisonGuard<'_, '_, Guard,
}
#[mutants::skip] // it's hard to get two guards safely
+#[cfg(not(tarpaulin_include))]
impl<Guard: Eq, Key: Keyable> Eq for PoisonGuard<'_, '_, Guard, Key> {}
#[mutants::skip] // it's hard to get two guards safely
+#[cfg(not(tarpaulin_include))]
impl<Guard: Ord, Key: Keyable> Ord for PoisonGuard<'_, '_, Guard, Key> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.guard.cmp(&other.guard)
@@ -119,6 +125,7 @@ impl<Guard: Ord, Key: Keyable> Ord for PoisonGuard<'_, '_, Guard, Key> {
}
#[mutants::skip] // hashing involves RNG and is hard to test
+#[cfg(not(tarpaulin_include))]
impl<Guard: Hash, Key: Keyable> Hash for PoisonGuard<'_, '_, Guard, Key> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.guard.hash(state)
@@ -126,6 +133,7 @@ impl<Guard: Hash, Key: Keyable> Hash for PoisonGuard<'_, '_, Guard, Key> {
}
#[mutants::skip]
+#[cfg(not(tarpaulin_include))]
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)
diff --git a/src/poisonable/poisonable.rs b/src/poisonable/poisonable.rs
index 0bc2b03..2dac4bb 100644
--- a/src/poisonable/poisonable.rs
+++ b/src/poisonable/poisonable.rs
@@ -13,6 +13,7 @@ use super::{
unsafe impl<L: Lockable + RawLock> RawLock for Poisonable<L> {
#[mutants::skip] // this should never run
+ #[cfg(not(tarpaulin_include))]
fn poison(&self) {
self.inner.poison()
}