summaryrefslogtreecommitdiff
path: root/src/poisonable/guard.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/poisonable/guard.rs')
-rwxr-xr-xsrc/poisonable/guard.rs26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/poisonable/guard.rs b/src/poisonable/guard.rs
index 32b4ee8..c4d9250 100755
--- a/src/poisonable/guard.rs
+++ b/src/poisonable/guard.rs
@@ -1,16 +1,18 @@
-use std::fmt::{Debug, Display};
-use std::hash::Hash;
-use std::marker::PhantomData;
-use std::ops::{Deref, DerefMut};
+use core::fmt::{Debug, Display};
+use core::hash::Hash;
+use core::marker::PhantomData;
+use core::ops::{Deref, DerefMut};
use super::{PoisonFlag, PoisonGuard, PoisonRef};
impl<'a, Guard> PoisonRef<'a, Guard> {
// This is used so that we don't keep accidentally adding the flag reference
+ #[allow(clippy::allow_attributes)]
+ #[allow(unused_variables)]
pub(super) const fn new(flag: &'a PoisonFlag, guard: Guard) -> Self {
Self {
guard,
- #[cfg(panic = "unwind")]
+ #[cfg(all(feature = "std", panic = "unwind"))]
flag,
_phantom: PhantomData,
}
@@ -19,7 +21,7 @@ impl<'a, Guard> PoisonRef<'a, Guard> {
impl<Guard> Drop for PoisonRef<'_, Guard> {
fn drop(&mut self) {
- #[cfg(panic = "unwind")]
+ #[cfg(all(feature = "std", panic = "unwind"))]
if std::thread::panicking() {
self.flag.poison();
}
@@ -29,7 +31,7 @@ impl<Guard> Drop 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) {
+ fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.guard.hash(state)
}
}
@@ -37,13 +39,13 @@ 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 {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Debug::fmt(&**self, f)
}
}
impl<Guard: Display> Display for PoisonRef<'_, Guard> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Display::fmt(&**self, f)
}
}
@@ -77,7 +79,7 @@ impl<Guard> AsMut<Guard> for PoisonRef<'_, Guard> {
#[mutants::skip] // hashing involves RNG and is hard to test
#[cfg(not(tarpaulin_include))]
impl<Guard: Hash> Hash for PoisonGuard<'_, Guard> {
- fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
+ fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
self.guard.hash(state)
}
}
@@ -85,13 +87,13 @@ impl<Guard: Hash> Hash for PoisonGuard<'_, Guard> {
#[mutants::skip]
#[cfg(not(tarpaulin_include))]
impl<Guard: Debug> Debug for PoisonGuard<'_, Guard> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Debug::fmt(&self.guard, f)
}
}
impl<Guard: Display> Display for PoisonGuard<'_, Guard> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
Display::fmt(&self.guard, f)
}
}