diff options
Diffstat (limited to 'src/poisonable')
| -rwxr-xr-x | src/poisonable/error.rs | 2 | ||||
| -rwxr-xr-x | src/poisonable/flag.rs | 2 | ||||
| -rwxr-xr-x | src/poisonable/guard.rs | 26 | ||||
| -rwxr-xr-x | src/poisonable/poisonable.rs | 4 |
4 files changed, 19 insertions, 15 deletions
diff --git a/src/poisonable/error.rs b/src/poisonable/error.rs index eed454b..b7b9206 100755 --- a/src/poisonable/error.rs +++ b/src/poisonable/error.rs @@ -1,5 +1,5 @@ +use core::error::Error; use core::fmt; -use std::error::Error; use super::{PoisonError, PoisonGuard, TryLockPoisonableError}; diff --git a/src/poisonable/flag.rs b/src/poisonable/flag.rs index 9186bbc..9877245 100755 --- a/src/poisonable/flag.rs +++ b/src/poisonable/flag.rs @@ -1,5 +1,5 @@ #[cfg(panic = "unwind")] -use std::sync::atomic::{AtomicBool, Ordering::Relaxed}; +use core::sync::atomic::{AtomicBool, Ordering::Relaxed}; use super::PoisonFlag; 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) } } diff --git a/src/poisonable/poisonable.rs b/src/poisonable/poisonable.rs index 0134ff1..ccca07e 100755 --- a/src/poisonable/poisonable.rs +++ b/src/poisonable/poisonable.rs @@ -1,4 +1,6 @@ -use std::panic::{RefUnwindSafe, UnwindSafe}; +use core::panic::{RefUnwindSafe, UnwindSafe}; + +use alloc::vec::Vec; use crate::collection::OwnedLockCollection; use crate::handle_unwind::handle_unwind; |
