Improve RwLock::new's docs

Fixes #21440"
This commit is contained in:
Steve Klabnik 2015-01-21 14:54:17 -05:00
parent 6869645e86
commit bbbdd1086c
1 changed files with 9 additions and 1 deletions

View File

@ -157,7 +157,15 @@ pub struct RwLockWriteGuard<'a, T: 'a> {
impl<'a, T> !marker::Send for RwLockWriteGuard<'a, T> {}
impl<T: Send + Sync> RwLock<T> {
/// Creates a new instance of an RwLock which is unlocked and read to go.
/// Creates a new instance of an `RwLock<T>` which is unlocked.
///
/// # Examples
///
/// ```
/// use std::sync::RwLock;
///
/// let lock = RwLock::new(5);
/// ```
#[stable]
pub fn new(t: T) -> RwLock<T> {
RwLock { inner: box RW_LOCK_INIT, data: UnsafeCell::new(t) }