diff options
Diffstat (limited to 'src/rwlock')
| -rw-r--r-- | src/rwlock/read_lock.rs | 2 | ||||
| -rw-r--r-- | src/rwlock/rwlock.rs | 12 | ||||
| -rw-r--r-- | src/rwlock/write_lock.rs | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/rwlock/read_lock.rs b/src/rwlock/read_lock.rs index c5c4c8c..e518cf3 100644 --- a/src/rwlock/read_lock.rs +++ b/src/rwlock/read_lock.rs @@ -72,7 +72,7 @@ impl<T: ?Sized, R: RawRwLock> ReadLock<'_, T, R> { pub fn try_lock<'s, 'key: 's, Key: Keyable + 'key>( &'s self, key: Key, - ) -> Option<RwLockReadGuard<'s, 'key, T, Key, R>> { + ) -> Result<RwLockReadGuard<'s, 'key, T, Key, R>, Key> { self.0.try_read(key) } diff --git a/src/rwlock/rwlock.rs b/src/rwlock/rwlock.rs index 03b2cfd..b5dea75 100644 --- a/src/rwlock/rwlock.rs +++ b/src/rwlock/rwlock.rs @@ -286,13 +286,13 @@ impl<T: ?Sized, R: RawRwLock> RwLock<T, R> { pub fn try_read<'s, 'key: 's, Key: Keyable>( &'s self, key: Key, - ) -> Option<RwLockReadGuard<'s, 'key, T, Key, R>> { + ) -> Result<RwLockReadGuard<'s, 'key, T, Key, R>, Key> { unsafe { if self.raw_try_read() { // safety: the lock is locked first - Some(RwLockReadGuard::new(self, key)) + Ok(RwLockReadGuard::new(self, key)) } else { - None + Err(key) } } } @@ -381,13 +381,13 @@ impl<T: ?Sized, R: RawRwLock> RwLock<T, R> { pub fn try_write<'s, 'key: 's, Key: Keyable>( &'s self, key: Key, - ) -> Option<RwLockWriteGuard<'s, 'key, T, Key, R>> { + ) -> Result<RwLockWriteGuard<'s, 'key, T, Key, R>, Key> { unsafe { if self.raw_try_lock() { // safety: the lock is locked first - Some(RwLockWriteGuard::new(self, key)) + Ok(RwLockWriteGuard::new(self, key)) } else { - None + Err(key) } } } diff --git a/src/rwlock/write_lock.rs b/src/rwlock/write_lock.rs index 77b68c8..ba05e87 100644 --- a/src/rwlock/write_lock.rs +++ b/src/rwlock/write_lock.rs @@ -73,7 +73,7 @@ impl<T: ?Sized, R: RawRwLock> WriteLock<'_, T, R> { pub fn try_lock<'s, 'key: 's, Key: Keyable + 'key>( &'s self, key: Key, - ) -> Option<RwLockWriteGuard<'s, 'key, T, Key, R>> { + ) -> Result<RwLockWriteGuard<'s, 'key, T, Key, R>, Key> { self.0.try_write(key) } |
