diff options
| author | Mica White <botahamec@outlook.com> | 2026-03-14 21:33:50 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-03-14 21:33:50 -0400 |
| commit | 482b47f4ed786946acb324b60d9f7ae7dd8cc075 (patch) | |
| tree | 4216f042597679f2b76adbb61d3ba9596e96a060 /src/rwlock/rwlock.rs | |
| parent | d9095d8fce59714f75019ecf68911d9931a1af15 (diff) | |
Diffstat (limited to 'src/rwlock/rwlock.rs')
| -rwxr-xr-x | src/rwlock/rwlock.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/rwlock/rwlock.rs b/src/rwlock/rwlock.rs index b93d8e2..6adf73a 100755 --- a/src/rwlock/rwlock.rs +++ b/src/rwlock/rwlock.rs @@ -573,11 +573,13 @@ impl<T: ?Sized, R: RawRwLock> RwLock<T, R> { /// Attempts to create a shared lock without a key. Locking this without /// exclusive access to the key is undefined behavior. pub(crate) unsafe fn try_read_no_key(&self) -> Option<RwLockReadRef<'_, T, R>> { - if self.raw_try_read() { - // safety: the lock is locked first - Some(RwLockReadRef(self, PhantomData)) - } else { - None + unsafe { + if self.raw_try_read() { + // safety: the lock is locked first + Some(RwLockReadRef(self, PhantomData)) + } else { + None + } } } @@ -585,11 +587,13 @@ impl<T: ?Sized, R: RawRwLock> RwLock<T, R> { /// without exclusive access to the key is undefined behavior. #[cfg(test)] pub(crate) unsafe fn try_write_no_key(&self) -> Option<RwLockWriteRef<'_, T, R>> { - if self.raw_try_write() { - // safety: the lock is locked first - Some(RwLockWriteRef(self, PhantomData)) - } else { - None + unsafe { + if self.raw_try_write() { + // safety: the lock is locked first + Some(RwLockWriteRef(self, PhantomData)) + } else { + None + } } } |
