Skip to content

Commit bbbdd10

Browse files
committed
Improve RwLock::new's docs
Fixes rust-lang#21440"
1 parent 6869645 commit bbbdd10

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/libstd/sync/rwlock.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,15 @@ pub struct RwLockWriteGuard<'a, T: 'a> {
157157
impl<'a, T> !marker::Send for RwLockWriteGuard<'a, T> {}
158158

159159
impl<T: Send + Sync> RwLock<T> {
160-
/// Creates a new instance of an RwLock which is unlocked and read to go.
160+
/// Creates a new instance of an `RwLock<T>` which is unlocked.
161+
///
162+
/// # Examples
163+
///
164+
/// ```
165+
/// use std::sync::RwLock;
166+
///
167+
/// let lock = RwLock::new(5);
168+
/// ```
161169
#[stable]
162170
pub fn new(t: T) -> RwLock<T> {
163171
RwLock { inner: box RW_LOCK_INIT, data: UnsafeCell::new(t) }

0 commit comments

Comments
 (0)