summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync/rwlock.rs
diff options
context:
space:
mode:
authorJake Rawsthorne <jake@jakerawsthorne.co.uk>2020-01-10 22:22:38 +0000
committerCarl Lerche <me@carllerche.com>2020-01-10 14:22:37 -0800
commita939dc48b0da9b62e361f4e82e79f48e70caa4be (patch)
treeb52b4f0260bd73612ba262e13086be354fd8f689 /tokio/src/sync/rwlock.rs
parentcfd9b36d89e6b665c11248a86de8934cb4a7bdff (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.rs15
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())
+ }
+}