From 1bfc6c1296c0b174577d6817557d0d1ed77687fb Mon Sep 17 00:00:00 2001 From: Eduardo Pinho Date: Sat, 18 Nov 2017 16:49:04 +0000 Subject: [PATCH] impl From for Mutex --- src/libstd/sync/mutex.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index eb507858b92b2..81f5594bc5231 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -382,6 +382,17 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex { } } +#[stable(feature = "mutex_from", since = "1.22.0")] +impl From for Mutex { + /// Creates a new mutex in an unlocked state ready for use. + /// This is equivalent to [`Mutex::new`]. + /// + /// [`Mutex::new`]: #method.new + fn from(t: T) -> Self { + Mutex::new(t) + } +} + #[stable(feature = "mutex_default", since = "1.10.0")] impl Default for Mutex { /// Creates a `Mutex`, with the `Default` value for T.