Skip to content

Commit

Permalink
impl From<T> for RwLock<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
Enet4 committed Nov 18, 2017
1 parent 1bfc6c1 commit 0855ea1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libstd/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,17 @@ impl<T: Default> Default for RwLock<T> {
}
}

#[stable(feature = "rw_lock_from", since = "1.22.0")]
impl<T> From<T> for RwLock<T> {
/// Creates a new instance of an `RwLock<T>` which is unlocked.
/// This is equivalent to [`RwLock::new`].
///
/// [`RwLock::new`]: #method.new
fn from(t: T) -> Self {
RwLock::new(t)
}
}

impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T> {
unsafe fn new(lock: &'rwlock RwLock<T>)
-> LockResult<RwLockReadGuard<'rwlock, T>> {
Expand Down

0 comments on commit 0855ea1

Please sign in to comment.