diff options
Diffstat (limited to 'src/rwlock.rs')
| -rwxr-xr-x | src/rwlock.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/rwlock.rs b/src/rwlock.rs index fca132d..bb9785a 100755 --- a/src/rwlock.rs +++ b/src/rwlock.rs @@ -1,5 +1,5 @@ -use std::cell::UnsafeCell; -use std::marker::PhantomData; +use core::cell::UnsafeCell; +use core::marker::PhantomData; use lock_api::RawRwLock; @@ -123,11 +123,14 @@ pub struct RwLockWriteGuard<'a, T: ?Sized, R: RawRwLock> { #[cfg(test)] mod tests { + #[cfg(feature = "std")] use crate::LockCollection; use crate::RwLock; + #[cfg(feature = "std")] use crate::ThreadKey; #[test] + #[cfg(feature = "std")] fn unlocked_when_initialized() { let key = ThreadKey::get().unwrap(); let lock: crate::RwLock<_> = RwLock::new("Hello, world!"); @@ -137,6 +140,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn locked_after_read() { let key = ThreadKey::get().unwrap(); let lock: crate::RwLock<_> = RwLock::new("Hello, world!"); @@ -148,6 +152,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn locked_after_write() { let key = ThreadKey::get().unwrap(); let lock: crate::RwLock<_> = RwLock::new("Hello, world!"); @@ -159,6 +164,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn locked_after_scoped_write() { let mut key = ThreadKey::get().unwrap(); let lock = crate::RwLock::new("Hello, world!"); @@ -177,6 +183,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn get_mut_works() { let key = ThreadKey::get().unwrap(); let mut lock = crate::RwLock::from(42); @@ -188,6 +195,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn try_write_can_fail() { let key = ThreadKey::get().unwrap(); let lock = crate::RwLock::new("Hello"); @@ -205,6 +213,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn try_read_can_fail() { let key = ThreadKey::get().unwrap(); let lock = crate::RwLock::new("Hello"); @@ -222,6 +231,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn read_display_works() { let key = ThreadKey::get().unwrap(); let lock: crate::RwLock<_> = RwLock::new("Hello, world!"); @@ -230,6 +240,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn write_display_works() { let key = ThreadKey::get().unwrap(); let lock: crate::RwLock<_> = RwLock::new("Hello, world!"); @@ -238,6 +249,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn read_ref_display_works() { let lock: crate::RwLock<_> = RwLock::new("Hello, world!"); let guard = unsafe { lock.try_read_no_key().unwrap() }; @@ -245,6 +257,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn write_ref_display_works() { let lock: crate::RwLock<_> = RwLock::new("Hello, world!"); let guard = unsafe { lock.try_write_no_key().unwrap() }; @@ -262,6 +275,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn dropping_write_guard_releases_rwlock() { let key = ThreadKey::get().unwrap(); let lock: crate::RwLock<_> = RwLock::new("Hello, world!"); @@ -273,6 +287,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn unlock_write() { let key = ThreadKey::get().unwrap(); let lock = crate::RwLock::new("Hello, world"); @@ -286,6 +301,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn unlock_read() { let key = ThreadKey::get().unwrap(); let lock = crate::RwLock::new("Hello, world"); @@ -299,6 +315,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn read_ref_as_ref() { let key = ThreadKey::get().unwrap(); let lock = LockCollection::new(crate::RwLock::new("hi")); @@ -308,6 +325,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn read_guard_as_ref() { let key = ThreadKey::get().unwrap(); let lock = crate::RwLock::new("hi"); @@ -317,6 +335,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn write_ref_as_ref() { let key = ThreadKey::get().unwrap(); let lock = LockCollection::new(crate::RwLock::new("hi")); @@ -326,6 +345,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn write_guard_as_ref() { let key = ThreadKey::get().unwrap(); let lock = crate::RwLock::new("hi"); @@ -335,6 +355,7 @@ mod tests { } #[test] + #[cfg(feature = "std")] fn write_guard_as_mut() { let key = ThreadKey::get().unwrap(); let lock = crate::RwLock::new("hi"); |
