diff options
Diffstat (limited to 'src/rwlock')
| -rwxr-xr-x | src/rwlock/read_guard.rs | 20 | ||||
| -rwxr-xr-x | src/rwlock/rwlock.rs | 15 | ||||
| -rwxr-xr-x | src/rwlock/write_guard.rs | 20 |
3 files changed, 29 insertions, 26 deletions
diff --git a/src/rwlock/read_guard.rs b/src/rwlock/read_guard.rs index f3161f5..7ca73d1 100755 --- a/src/rwlock/read_guard.rs +++ b/src/rwlock/read_guard.rs @@ -1,7 +1,7 @@ -use std::fmt::{Debug, Display}; -use std::hash::Hash; -use std::marker::PhantomData; -use std::ops::Deref; +use core::fmt::{Debug, Display}; +use core::hash::Hash; +use core::marker::PhantomData; +use core::ops::Deref; use lock_api::RawRwLock; @@ -16,7 +16,7 @@ use super::{RwLock, RwLockReadGuard, RwLockReadRef}; #[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> { - fn hash<H: std::hash::Hasher>(&self, state: &mut H) { + fn hash<H: core::hash::Hasher>(&self, state: &mut H) { self.deref().hash(state) } } @@ -24,13 +24,13 @@ impl<T: Hash + ?Sized, R: RawRwLock> Hash for RwLockReadRef<'_, T, R> { #[mutants::skip] #[cfg(not(tarpaulin_include))] impl<T: Debug + ?Sized, R: RawRwLock> Debug for RwLockReadRef<'_, T, R> { - 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<T: Display + ?Sized, R: RawRwLock> Display for RwLockReadRef<'_, T, R> { - 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) } } @@ -72,7 +72,7 @@ impl<'a, T: ?Sized, R: RawRwLock> RwLockReadRef<'a, T, R> { #[mutants::skip] // hashing involves PRNG and is hard to test #[cfg(not(tarpaulin_include))] impl<T: Hash + ?Sized, R: RawRwLock> Hash for RwLockReadGuard<'_, T, R> { - fn hash<H: std::hash::Hasher>(&self, state: &mut H) { + fn hash<H: core::hash::Hasher>(&self, state: &mut H) { self.deref().hash(state) } } @@ -80,13 +80,13 @@ impl<T: Hash + ?Sized, R: RawRwLock> Hash for RwLockReadGuard<'_, T, R> { #[mutants::skip] #[cfg(not(tarpaulin_include))] impl<T: Debug + ?Sized, R: RawRwLock> Debug for RwLockReadGuard<'_, T, R> { - 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<T: Display + ?Sized, R: RawRwLock> Display for RwLockReadGuard<'_, T, R> { - 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) } } diff --git a/src/rwlock/rwlock.rs b/src/rwlock/rwlock.rs index 6adf73a..72e7742 100755 --- a/src/rwlock/rwlock.rs +++ b/src/rwlock/rwlock.rs @@ -1,8 +1,9 @@ -use std::cell::UnsafeCell; -use std::fmt::Debug; -use std::marker::PhantomData; -use std::panic::AssertUnwindSafe; +use core::cell::UnsafeCell; +use core::fmt::Debug; +use core::marker::PhantomData; +use core::panic::AssertUnwindSafe; +use alloc::vec::Vec; use lock_api::RawRwLock; use crate::handle_unwind::handle_unwind; @@ -163,7 +164,7 @@ impl<T, R: RawRwLock> RwLock<T, R> { #[mutants::skip] #[cfg(not(tarpaulin_include))] impl<T: Debug, R: RawRwLock> Debug for RwLock<T, R> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { // safety: this is just a try lock, and the value is dropped // immediately after, so there's no risk of blocking ourselves // or any other threads @@ -172,7 +173,7 @@ impl<T: Debug, R: RawRwLock> Debug for RwLock<T, R> { } else { struct LockedPlaceholder; impl Debug for LockedPlaceholder { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.write_str("<locked>") } } @@ -586,6 +587,8 @@ impl<T: ?Sized, R: RawRwLock> RwLock<T, R> { /// Attempts to create an exclusive lock without a key. Locking this /// without exclusive access to the key is undefined behavior. #[cfg(test)] + #[allow(clippy::allow_attributes)] + #[allow(dead_code)] pub(crate) unsafe fn try_write_no_key(&self) -> Option<RwLockWriteRef<'_, T, R>> { unsafe { if self.raw_try_write() { diff --git a/src/rwlock/write_guard.rs b/src/rwlock/write_guard.rs index 823f7a4..5e367bd 100755 --- a/src/rwlock/write_guard.rs +++ b/src/rwlock/write_guard.rs @@ -1,7 +1,7 @@ -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 lock_api::RawRwLock; @@ -16,7 +16,7 @@ use super::{RwLock, RwLockWriteGuard, RwLockWriteRef}; #[mutants::skip] // hashing involves PRNG and is difficult to test #[cfg(not(tarpaulin_include))] impl<T: Hash + ?Sized, R: RawRwLock> Hash for RwLockWriteRef<'_, T, R> { - fn hash<H: std::hash::Hasher>(&self, state: &mut H) { + fn hash<H: core::hash::Hasher>(&self, state: &mut H) { self.deref().hash(state) } } @@ -24,13 +24,13 @@ impl<T: Hash + ?Sized, R: RawRwLock> Hash for RwLockWriteRef<'_, T, R> { #[mutants::skip] #[cfg(not(tarpaulin_include))] impl<T: Debug + ?Sized, R: RawRwLock> Debug for RwLockWriteRef<'_, T, R> { - 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<T: Display + ?Sized, R: RawRwLock> Display for RwLockWriteRef<'_, T, R> { - 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) } } @@ -87,7 +87,7 @@ impl<'a, T: ?Sized + 'a, R: RawRwLock> RwLockWriteRef<'a, T, R> { #[mutants::skip] // hashing involves PRNG and is difficult to test #[cfg(not(tarpaulin_include))] impl<T: Hash + ?Sized, R: RawRwLock> Hash for RwLockWriteGuard<'_, T, R> { - fn hash<H: std::hash::Hasher>(&self, state: &mut H) { + fn hash<H: core::hash::Hasher>(&self, state: &mut H) { self.deref().hash(state) } } @@ -95,13 +95,13 @@ impl<T: Hash + ?Sized, R: RawRwLock> Hash for RwLockWriteGuard<'_, T, R> { #[mutants::skip] #[cfg(not(tarpaulin_include))] impl<T: Debug + ?Sized, R: RawRwLock> Debug for RwLockWriteGuard<'_, T, R> { - 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<T: Display + ?Sized, R: RawRwLock> Display for RwLockWriteGuard<'_, T, R> { - 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) } } |
