Skip to content

Commit 0855ea1

Browse files
committed
impl From<T> for RwLock<T>
1 parent 1bfc6c1 commit 0855ea1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libstd/sync/rwlock.rs

+11
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,17 @@ impl<T: Default> Default for RwLock<T> {
457457
}
458458
}
459459

460+
#[stable(feature = "rw_lock_from", since = "1.22.0")]
461+
impl<T> From<T> for RwLock<T> {
462+
/// Creates a new instance of an `RwLock<T>` which is unlocked.
463+
/// This is equivalent to [`RwLock::new`].
464+
///
465+
/// [`RwLock::new`]: #method.new
466+
fn from(t: T) -> Self {
467+
RwLock::new(t)
468+
}
469+
}
470+
460471
impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> {
461472
unsafe fn new(lock: &'rwlock RwLock<T>)
462473
-> LockResult<RwLockReadGuard<'rwlock, T>> {

0 commit comments

Comments
 (0)