1
Fork 0

impl From<T> for Mutex<T>

This commit is contained in:
Eduardo Pinho 2017-11-18 16:49:04 +00:00
parent 18250b0349
commit 1bfc6c1296

View file

@ -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.