Skip to content

Commit

Permalink
impl From<T> for Mutex<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
Enet4 committed Nov 18, 2017
1 parent 18250b0 commit 1bfc6c1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libstd/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 1bfc6c1

Please sign in to comment.