diff options
Diffstat (limited to 'src/mutex.rs')
-rw-r--r-- | src/mutex.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mutex.rs b/src/mutex.rs index 51192a8..aca5669 100644 --- a/src/mutex.rs +++ b/src/mutex.rs @@ -4,8 +4,10 @@ pub fn new<T>(t: T) -> async_std::sync::Arc<async_std::sync::Mutex<T>> { async_std::sync::Arc::new(async_std::sync::Mutex::new(t)) } -pub fn unwrap<T: std::fmt::Debug>(t: Mutex<T>) -> T { - async_std::sync::Mutex::into_inner( - async_std::sync::Arc::try_unwrap(t).unwrap(), - ) +pub fn unwrap<T: std::fmt::Debug>(t: Mutex<T>) -> Option<T> { + if let Ok(mutex) = async_std::sync::Arc::try_unwrap(t) { + Some(async_std::sync::Mutex::into_inner(mutex)) + } else { + None + } } |