sync: impl From<T> and Default for RwLock (#2089)

This commit is contained in:
Jake Rawsthorne
2020-01-10 14:22:37 -08:00
committed by Carl Lerche
parent cfd9b36d89
commit a939dc48b0
+15
View File
@@ -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())
}
}