We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 18250b0 commit 1bfc6c1Copy full SHA for 1bfc6c1
src/libstd/sync/mutex.rs
@@ -382,6 +382,17 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex<T> {
382
}
383
384
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
+
396
#[stable(feature = "mutex_default", since = "1.10.0")]
397
impl<T: ?Sized + Default> Default for Mutex<T> {
398
/// Creates a `Mutex<T>`, with the `Default` value for T.
0 commit comments