diff options
| author | Eduardo Pinho <enet4mikeenet@gmail.com> | 2017-11-18 16:49:04 +0000 |
|---|---|---|
| committer | Eduardo Pinho <enet4mikeenet@gmail.com> | 2017-11-18 16:52:46 +0000 |
| commit | 1bfc6c1296c0b174577d6817557d0d1ed77687fb (patch) | |
| tree | 03c385921be5fb1230dd78f571ad63968975f1e5 /src/libstd/sync | |
| parent | 18250b0349848fbfca53153cf121724c773dd508 (diff) | |
| download | rust-1bfc6c1296c0b174577d6817557d0d1ed77687fb.tar.gz rust-1bfc6c1296c0b174577d6817557d0d1ed77687fb.zip | |
impl From<T> for Mutex<T>
Diffstat (limited to 'src/libstd/sync')
| -rw-r--r-- | src/libstd/sync/mutex.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index eb507858b92..81f5594bc52 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<T> { } } +#[stable(feature = "mutex_from", since = "1.22.0")] +impl<T> From<T> for Mutex<T> { + /// 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<T: ?Sized + Default> Default for Mutex<T> { /// Creates a `Mutex<T>`, with the `Default` value for T. |
