From 657377311d3b041ac7b942e61ddbbe2861c494ec Mon Sep 17 00:00:00 2001 From: Mica White Date: Wed, 25 Dec 2024 11:17:35 -0500 Subject: try_lock returns a Result --- src/rwlock/rwlock.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/rwlock/rwlock.rs') 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 RwLock { pub fn try_read<'s, 'key: 's, Key: Keyable>( &'s self, key: Key, - ) -> Option> { + ) -> Result, 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 RwLock { pub fn try_write<'s, 'key: 's, Key: Keyable>( &'s self, key: Key, - ) -> Option> { + ) -> Result, 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) } } } -- cgit v1.2.3