Skip to content

Commit 1bfc6c1

Browse files
committed
impl From<T> for Mutex<T>
1 parent 18250b0 commit 1bfc6c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libstd/sync/mutex.rs

+11
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,17 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex<T> {
382382
}
383383
}
384384

385+
#[stable(feature = "mutex_from", since = "1.22.0")]
386+
impl<T> From<T> for Mutex<T> {
387+
/// Creates a new mutex in an unlocked state ready for use.
388+
/// This is equivalent to [`Mutex::new`].
389+
///
390+
/// [`Mutex::new`]: #method.new
391+
fn from(t: T) -> Self {
392+
Mutex::new(t)
393+
}
394+
}
395+
385396
#[stable(feature = "mutex_default", since = "1.10.0")]
386397
impl<T: ?Sized + Default> Default for Mutex<T> {
387398
/// Creates a `Mutex<T>`, with the `Default` value for T.

0 commit comments

Comments
 (0)