summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync/mutex.rs
diff options
context:
space:
mode:
authorWaffle Lapkin <waffle.lapkin@gmail.com>2020-02-17 19:16:48 +0300
committerGitHub <noreply@github.com>2020-02-17 11:16:48 -0500
commit09b5f47381dba99e1fcf666e0639cff627048ad2 (patch)
treef043a6b80aee2c72f598667c3c7709c1446aa1ef /tokio/src/sync/mutex.rs
parentfc65951731506ba4bbbc08eed256b5e8b0d46655 (diff)
Add `Mutex::into_inner` method (#2250)
Add `Mutex::into_inner` method that consumes mutex and return underlying value. Fixes: #2211
Diffstat (limited to 'tokio/src/sync/mutex.rs')
-rw-r--r--tokio/src/sync/mutex.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/tokio/src/sync/mutex.rs b/tokio/src/sync/mutex.rs
index c625ce27..92218cbc 100644
--- a/tokio/src/sync/mutex.rs
+++ b/tokio/src/sync/mutex.rs
@@ -174,6 +174,11 @@ impl<T> Mutex<T> {
Err(_) => Err(TryLockError(())),
}
}
+
+ /// Consumes the mutex, returning the underlying data.
+ pub fn into_inner(self) -> T {
+ self.c.into_inner()
+ }
}
impl<'a, T> Drop for MutexGuard<'a, T> {