diff options
author | Daniel Müller <d-e-s-o@users.noreply.github.com> | 2020-03-18 11:52:11 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-18 11:52:11 -0700 |
commit | c3b830110aa3f13346721dc148e074c122c7ddbe (patch) | |
tree | 26c9b9b08fcf564f6b2c1f28cddbf45cc8736809 /tokio/src/sync/rwlock.rs | |
parent | 602ad2e0ba41467f08052e152d5808ee6a695afe (diff) |
sync: Add RwLock::into_inner method (#2321)
Add RwLock::into_inner method that consumes the lock and returns
the wrapped value.
Fixes: #2320
Diffstat (limited to 'tokio/src/sync/rwlock.rs')
-rw-r--r-- | tokio/src/sync/rwlock.rs | 5 |
1 files changed, 5 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> { |