diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-01-08 06:54:39 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-01-08 07:16:35 -0500 |
commit | 43600665dc50abae7f9d90d171cd14f51ba92448 (patch) | |
tree | 4a1d914e46a31b174723ef018510323f04f65d70 /src/mutex.rs | |
parent | 71df59851586f7221accf95289962fe61c63fb90 (diff) | |
download | nbsh-43600665dc50abae7f9d90d171cd14f51ba92448.tar.gz nbsh-43600665dc50abae7f9d90d171cd14f51ba92448.zip |
refactor builtin fd handling a bit
Diffstat (limited to 'src/mutex.rs')
-rw-r--r-- | src/mutex.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mutex.rs b/src/mutex.rs new file mode 100644 index 0000000..51192a8 --- /dev/null +++ b/src/mutex.rs @@ -0,0 +1,11 @@ +pub type Mutex<T> = async_std::sync::Arc<async_std::sync::Mutex<T>>; + +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(), + ) +} |