diff options
| author | Mica White <botahamec@outlook.com> | 2026-09-13 15:12:08 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-09-13 15:12:08 -0400 |
| commit | 16d6bd7ece4c4b9b72f6bd51c9b034270b745525 (patch) | |
| tree | 4ff744fc41319ce73abe06416fabeaa7c17fbd46 /src/mutex | |
| parent | 9fd7b94cd7c20abe66cea875a0e83e76a7a00fbc (diff) | |
Support no_stdno-std
Diffstat (limited to 'src/mutex')
| -rwxr-xr-x | src/mutex/guard.rs | 20 | ||||
| -rwxr-xr-x | src/mutex/mutex.rs | 13 |
2 files changed, 17 insertions, 16 deletions
diff --git a/src/mutex/guard.rs b/src/mutex/guard.rs index 538a08a..dad1cd7 100755 --- a/src/mutex/guard.rs +++ b/src/mutex/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::RawMutex; @@ -16,7 +16,7 @@ use super::{Mutex, MutexGuard, MutexRef}; #[mutants::skip] // hashing involves RNG and is hard to test #[cfg(not(tarpaulin_include))] impl<T: Hash + ?Sized, R: RawMutex> Hash for MutexRef<'_, 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: RawMutex> Hash for MutexRef<'_, T, R> { #[mutants::skip] #[cfg(not(tarpaulin_include))] impl<T: Debug + ?Sized, R: RawMutex> Debug for MutexRef<'_, 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: RawMutex> Display for MutexRef<'_, 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) } } @@ -90,7 +90,7 @@ impl<'a, T: ?Sized, R: RawMutex> MutexRef<'a, T, R> { #[mutants::skip] // hashing involves RNG and is hard to test #[cfg(not(tarpaulin_include))] impl<T: Hash + ?Sized, R: RawMutex> Hash for MutexGuard<'_, 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) } } @@ -98,13 +98,13 @@ impl<T: Hash + ?Sized, R: RawMutex> Hash for MutexGuard<'_, T, R> { #[mutants::skip] #[cfg(not(tarpaulin_include))] impl<T: Debug + ?Sized, R: RawMutex> Debug for MutexGuard<'_, 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: RawMutex> Display for MutexGuard<'_, 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/mutex/mutex.rs b/src/mutex/mutex.rs index dc374aa..f6db081 100755 --- a/src/mutex/mutex.rs +++ b/src/mutex/mutex.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::RawMutex; use crate::handle_unwind::handle_unwind; @@ -147,7 +148,7 @@ impl<T, R: RawMutex> Mutex<T, R> { #[mutants::skip] #[cfg(not(tarpaulin_include))] impl<T: ?Sized + Debug, R: RawMutex> Debug for Mutex<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 @@ -157,7 +158,7 @@ impl<T: ?Sized + Debug, R: RawMutex> Debug for Mutex<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>") } } |
