From efc0244ba679058938aca0e0fe1dc518891dbfc7 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 7 Jan 2023 20:11:05 +0000 Subject: [PATCH] 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`. --- lightning/src/sync.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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(()) + } } } -- 2.39.5