summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tokio/src/sync/rwlock.rs5
-rw-r--r--tokio/tests/sync_rwlock.rs6
2 files changed, 11 insertions, 0 deletions
diff --git a/tokio/src/sync/rwlock.rs b/tokio/src/sync/rwlock.rs
index ccd0e884..97921b9f 100644
--- a/tokio/src/sync/rwlock.rs
+++ b/tokio/src/sync/rwlock.rs
@@ -244,6 +244,11 @@ impl<T> RwLock<T> {
RwLockWriteGuard { lock: self, permit }
}
+
+ /// Consumes the lock, returning the underlying data.
+ pub fn into_inner(self) -> T {
+ self.c.into_inner()
+ }
}
impl<T> ops::Deref for RwLockReadGuard<'_, T> {
diff --git a/tokio/tests/sync_rwlock.rs b/tokio/tests/sync_rwlock.rs
index f4a933cb..87010b65 100644
--- a/tokio/tests/sync_rwlock.rs
+++ b/tokio/tests/sync_rwlock.rs
@@ -11,6 +11,12 @@ use tokio::sync::{Barrier, RwLock};
use tokio_test::task::spawn;
use tokio_test::{assert_pending, assert_ready};
+#[test]
+fn into_inner() {
+ let rwlock = RwLock::new(42);
+ assert_eq!(rwlock.into_inner(), 42);
+}
+
// multiple reads should be Ready
#[test]
fn read_shared() {