diff options
author | Jake Rawsthorne <jake@jakerawsthorne.co.uk> | 2020-01-10 22:22:38 +0000 |
---|---|---|
committer | Carl Lerche <me@carllerche.com> | 2020-01-10 14:22:37 -0800 |
commit | a939dc48b0da9b62e361f4e82e79f48e70caa4be (patch) | |
tree | b52b4f0260bd73612ba262e13086be354fd8f689 /tokio/src/sync/rwlock.rs | |
parent | cfd9b36d89e6b665c11248a86de8934cb4a7bdff (diff) |
sync: impl From<T> and Default for RwLock (#2089)
Diffstat (limited to 'tokio/src/sync/rwlock.rs')
-rw-r--r-- | tokio/src/sync/rwlock.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tokio/src/sync/rwlock.rs b/tokio/src/sync/rwlock.rs index ad27dbff..b859813a 100644 --- a/tokio/src/sync/rwlock.rs +++ b/tokio/src/sync/rwlock.rs @@ -254,3 +254,18 @@ impl<T> ops::DerefMut for RwLockWriteGuard<'_, T> { unsafe { &mut *self.lock.c.get() } } } + +impl<T> From<T> for RwLock<T> { + fn from(s: T) -> Self { + Self::new(s) + } +} + +impl<T> Default for RwLock<T> +where + T: Default, +{ + fn default() -> Self { + Self::new(T::default()) + } +} |