about summary refs log tree commit diff
path: root/src/libstd/sync
diff options
context:
space:
mode:
authorEduardo Pinho <enet4mikeenet@gmail.com>2017-11-18 21:05:06 +0000
committerEduardo Pinho <enet4mikeenet@gmail.com>2017-11-18 21:05:06 +0000
commit0855ea18324f06896818c7df920a5091aa931ff6 (patch)
tree31c4c0467b3762640e9cb3ef4a017fb6603e236a /src/libstd/sync
parent1bfc6c1296c0b174577d6817557d0d1ed77687fb (diff)
downloadrust-0855ea18324f06896818c7df920a5091aa931ff6.tar.gz
rust-0855ea18324f06896818c7df920a5091aa931ff6.zip
impl From<T> for RwLock<T>
Diffstat (limited to 'src/libstd/sync')
-rw-r--r--src/libstd/sync/rwlock.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs
index 6216d78528d..fd6cff6b69c 100644
--- a/src/libstd/sync/rwlock.rs
+++ b/src/libstd/sync/rwlock.rs
@@ -457,6 +457,17 @@ impl<T: Default> Default for RwLock<T> {
     }
 }
 
+#[stable(feature = "rw_lock_from", since = "1.22.0")]
+impl<T> From<T> for RwLock<T> {
+    /// Creates a new instance of an `RwLock<T>` which is unlocked.
+    /// This is equivalent to [`RwLock::new`].
+    ///
+    /// [`RwLock::new`]: #method.new
+    fn from(t: T) -> Self {
+        RwLock::new(t)
+    }
+}
+
 impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> {
     unsafe fn new(lock: &'rwlock RwLock<T>)
                   -> LockResult<RwLockReadGuard<'rwlock, T>> {