From: Matt Corallo Date: Sat, 7 Jan 2023 20:11:05 +0000 (+0000) Subject: Make the no-std `RwLockGuard` `try_lock` actually try X-Git-Tag: v0.0.114-beta~71^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=efc0244ba679058938aca0e0fe1dc518891dbfc7;p=rust-lightning Make the no-std `RwLockGuard` `try_lock` actually try There doesn't appear to be any reason to have `try_lock` fail, and future work shouldn't need to check for std to use `try_lock`. --- diff --git a/lightning/src/sync.rs b/lightning/src/sync.rs index 482759b8c..caf88a7cc 100644 --- a/lightning/src/sync.rs +++ b/lightning/src/sync.rs @@ -109,8 +109,10 @@ impl RwLock { } pub fn try_write<'a>(&'a self) -> LockResult> { - // There is no try, grasshopper - only used for tests and expected to fail - Err(()) + match self.inner.try_borrow_mut() { + Ok(lock) => Ok(RwLockWriteGuard { lock }), + Err(_) => Err(()) + } } }