1
Fork 0

Auto merge of #75790 - LeSeulArtichaut:std-intra-doc, r=jyn514

Use intra-doc-links in `std::sync::*`

Helps with #75080.
r? @jyn514
This commit is contained in:
bors 2020-08-22 08:54:29 +00:00
commit c5a8b7b901
4 changed files with 53 additions and 136 deletions

View file

@ -11,7 +11,7 @@ use crate::time::{Duration, Instant};
/// ///
/// It is returned by the [`wait_timeout`] method. /// It is returned by the [`wait_timeout`] method.
/// ///
/// [`wait_timeout`]: struct.Condvar.html#method.wait_timeout /// [`wait_timeout`]: Condvar::wait_timeout
#[derive(Debug, PartialEq, Eq, Copy, Clone)] #[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[stable(feature = "wait_timeout", since = "1.5.0")] #[stable(feature = "wait_timeout", since = "1.5.0")]
pub struct WaitTimeoutResult(bool); pub struct WaitTimeoutResult(bool);
@ -161,11 +161,10 @@ impl Condvar {
/// mutex to ensure defined behavior across platforms. If this functionality /// mutex to ensure defined behavior across platforms. If this functionality
/// is not desired, then unsafe primitives in `sys` are provided. /// is not desired, then unsafe primitives in `sys` are provided.
/// ///
/// [`notify_one`]: #method.notify_one /// [`notify_one`]: Self::notify_one
/// [`notify_all`]: #method.notify_all /// [`notify_all`]: Self::notify_all
/// [poisoning]: ../sync/struct.Mutex.html#poisoning /// [poisoning]: super::Mutex#poisoning
/// [`Mutex`]: ../sync/struct.Mutex.html /// [`Mutex`]: super::Mutex
/// [`panic!`]: ../../std/macro.panic.html
/// ///
/// # Examples /// # Examples
/// ///
@ -218,10 +217,10 @@ impl Condvar {
/// poisoned when this thread re-acquires the lock. For more information, /// poisoned when this thread re-acquires the lock. For more information,
/// see information about [poisoning] on the [`Mutex`] type. /// see information about [poisoning] on the [`Mutex`] type.
/// ///
/// [`notify_one`]: #method.notify_one /// [`notify_one`]: Self::notify_one
/// [`notify_all`]: #method.notify_all /// [`notify_all`]: Self::notify_all
/// [poisoning]: ../sync/struct.Mutex.html#poisoning /// [poisoning]: super::Mutex#poisoning
/// [`Mutex`]: ../sync/struct.Mutex.html /// [`Mutex`]: super::Mutex
/// ///
/// # Examples /// # Examples
/// ///
@ -280,7 +279,7 @@ impl Condvar {
/// Like [`wait`], the lock specified will be re-acquired when this function /// Like [`wait`], the lock specified will be re-acquired when this function
/// returns, regardless of whether the timeout elapsed or not. /// returns, regardless of whether the timeout elapsed or not.
/// ///
/// [`wait`]: #method.wait /// [`wait`]: Self::wait
/// ///
/// # Examples /// # Examples
/// ///
@ -350,9 +349,8 @@ impl Condvar {
/// Like [`wait`], the lock specified will be re-acquired when this function /// Like [`wait`], the lock specified will be re-acquired when this function
/// returns, regardless of whether the timeout elapsed or not. /// returns, regardless of whether the timeout elapsed or not.
/// ///
/// [`wait`]: #method.wait /// [`wait`]: Self::wait
/// [`wait_timeout_while`]: #method.wait_timeout_while /// [`wait_timeout_while`]: Self::wait_timeout_while
/// [`WaitTimeoutResult`]: struct.WaitTimeoutResult.html
/// ///
/// # Examples /// # Examples
/// ///
@ -420,9 +418,8 @@ impl Condvar {
/// Like [`wait_while`], the lock specified will be re-acquired when this /// Like [`wait_while`], the lock specified will be re-acquired when this
/// function returns, regardless of whether the timeout elapsed or not. /// function returns, regardless of whether the timeout elapsed or not.
/// ///
/// [`wait_while`]: #method.wait_while /// [`wait_while`]: Self::wait_while
/// [`wait_timeout`]: #method.wait_timeout /// [`wait_timeout`]: Self::wait_timeout
/// [`WaitTimeoutResult`]: struct.WaitTimeoutResult.html
/// ///
/// # Examples /// # Examples
/// ///
@ -485,9 +482,9 @@ impl Condvar {
/// ///
/// To wake up all threads, see [`notify_all`]. /// To wake up all threads, see [`notify_all`].
/// ///
/// [`wait`]: #method.wait /// [`wait`]: Self::wait
/// [`wait_timeout`]: #method.wait_timeout /// [`wait_timeout`]: Self::wait_timeout
/// [`notify_all`]: #method.notify_all /// [`notify_all`]: Self::notify_all
/// ///
/// # Examples /// # Examples
/// ///
@ -527,7 +524,7 @@ impl Condvar {
/// ///
/// To wake up only one thread, see [`notify_one`]. /// To wake up only one thread, see [`notify_one`].
/// ///
/// [`notify_one`]: #method.notify_one /// [`notify_one`]: Self::notify_one
/// ///
/// # Examples /// # Examples
/// ///

View file

@ -1,5 +1,3 @@
// ignore-tidy-filelength
//! Multi-producer, single-consumer FIFO queue communication primitives. //! Multi-producer, single-consumer FIFO queue communication primitives.
//! //!
//! This module provides message-based communication over channels, concretely //! This module provides message-based communication over channels, concretely
@ -27,12 +25,7 @@
//! that a bound of 0 is allowed, causing the channel to become a "rendezvous" //! that a bound of 0 is allowed, causing the channel to become a "rendezvous"
//! channel where each sender atomically hands off a message to a receiver. //! channel where each sender atomically hands off a message to a receiver.
//! //!
//! [`Sender`]: ../../../std/sync/mpsc/struct.Sender.html //! [`send`]: Sender::send
//! [`SyncSender`]: ../../../std/sync/mpsc/struct.SyncSender.html
//! [`Receiver`]: ../../../std/sync/mpsc/struct.Receiver.html
//! [`send`]: ../../../std/sync/mpsc/struct.Sender.html#method.send
//! [`channel`]: ../../../std/sync/mpsc/fn.channel.html
//! [`sync_channel`]: ../../../std/sync/mpsc/fn.sync_channel.html
//! //!
//! ## Disconnection //! ## Disconnection
//! //!
@ -46,9 +39,7 @@
//! will continue to [`unwrap`] the results returned from this module, //! will continue to [`unwrap`] the results returned from this module,
//! instigating a propagation of failure among threads if one unexpectedly dies. //! instigating a propagation of failure among threads if one unexpectedly dies.
//! //!
//! [`Result`]: ../../../std/result/enum.Result.html //! [`unwrap`]: Result::unwrap
//! [`Err`]: ../../../std/result/enum.Result.html#variant.Err
//! [`unwrap`]: ../../../std/result/enum.Result.html#method.unwrap
//! //!
//! # Examples //! # Examples
//! //!
@ -291,9 +282,7 @@ mod cache_aligned;
/// ///
/// Messages sent to the channel can be retrieved using [`recv`]. /// Messages sent to the channel can be retrieved using [`recv`].
/// ///
/// [`channel`]: fn.channel.html /// [`recv`]: Receiver::recv
/// [`sync_channel`]: fn.sync_channel.html
/// [`recv`]: struct.Receiver.html#method.recv
/// ///
/// # Examples /// # Examples
/// ///
@ -333,10 +322,8 @@ impl<T> !Sync for Receiver<T> {}
/// waiting for a new message, and [`None`] will be returned /// waiting for a new message, and [`None`] will be returned
/// when the corresponding channel has hung up. /// when the corresponding channel has hung up.
/// ///
/// [`iter`]: struct.Receiver.html#method.iter /// [`iter`]: Receiver::iter
/// [`Receiver`]: struct.Receiver.html /// [`next`]: Iterator::next
/// [`next`]: ../../../std/iter/trait.Iterator.html#tymethod.next
/// [`None`]: ../../../std/option/enum.Option.html#variant.None
/// ///
/// # Examples /// # Examples
/// ///
@ -371,9 +358,7 @@ pub struct Iter<'a, T: 'a> {
/// This iterator will never block the caller in order to wait for data to /// This iterator will never block the caller in order to wait for data to
/// become available. Instead, it will return [`None`]. /// become available. Instead, it will return [`None`].
/// ///
/// [`Receiver`]: struct.Receiver.html /// [`try_iter`]: Receiver::try_iter
/// [`try_iter`]: struct.Receiver.html#method.try_iter
/// [`None`]: ../../../std/option/enum.Option.html#variant.None
/// ///
/// # Examples /// # Examples
/// ///
@ -414,9 +399,7 @@ pub struct TryIter<'a, T: 'a> {
/// is called, waiting for a new message, and [`None`] will be /// is called, waiting for a new message, and [`None`] will be
/// returned if the corresponding channel has hung up. /// returned if the corresponding channel has hung up.
/// ///
/// [`Receiver`]: struct.Receiver.html /// [`next`]: Iterator::next
/// [`next`]: ../../../std/iter/trait.Iterator.html#tymethod.next
/// [`None`]: ../../../std/option/enum.Option.html#variant.None
/// ///
/// # Examples /// # Examples
/// ///
@ -447,8 +430,7 @@ pub struct IntoIter<T> {
/// ///
/// Messages can be sent through this channel with [`send`]. /// Messages can be sent through this channel with [`send`].
/// ///
/// [`channel`]: fn.channel.html /// [`send`]: Sender::send
/// [`send`]: struct.Sender.html#method.send
/// ///
/// # Examples /// # Examples
/// ///
@ -493,9 +475,8 @@ impl<T> !Sync for Sender<T> {}
/// ///
/// [`send`] will block if there is no space in the internal buffer. /// [`send`] will block if there is no space in the internal buffer.
/// ///
/// [`sync_channel`]: fn.sync_channel.html /// [`send`]: SyncSender::send
/// [`send`]: struct.SyncSender.html#method.send /// [`try_send`]: SyncSender::try_send
/// [`try_send`]: struct.SyncSender.html#method.try_send
/// ///
/// # Examples /// # Examples
/// ///
@ -549,8 +530,8 @@ unsafe impl<T: Send> Send for SyncSender<T> {}
/// disconnected, implying that the data could never be received. The error /// disconnected, implying that the data could never be received. The error
/// contains the data being sent as a payload so it can be recovered. /// contains the data being sent as a payload so it can be recovered.
/// ///
/// [`Sender::send`]: struct.Sender.html#method.send /// [`Sender::send`]: Sender::send
/// [`SyncSender::send`]: struct.SyncSender.html#method.send /// [`SyncSender::send`]: SyncSender::send
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[derive(PartialEq, Eq, Clone, Copy)] #[derive(PartialEq, Eq, Clone, Copy)]
pub struct SendError<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T); pub struct SendError<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T);
@ -561,10 +542,7 @@ pub struct SendError<T>(#[stable(feature = "rust1", since = "1.0.0")] pub T);
/// [`channel`] (or [`sync_channel`]) is disconnected, implying that no further /// [`channel`] (or [`sync_channel`]) is disconnected, implying that no further
/// messages will ever be received. /// messages will ever be received.
/// ///
/// [`recv`]: struct.Receiver.html#method.recv /// [`recv`]: Receiver::recv
/// [`Receiver`]: struct.Receiver.html
/// [`channel`]: fn.channel.html
/// [`sync_channel`]: fn.sync_channel.html
#[derive(PartialEq, Eq, Clone, Copy, Debug)] #[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct RecvError; pub struct RecvError;
@ -573,9 +551,7 @@ pub struct RecvError;
/// not return data when called. This can occur with both a [`channel`] and /// not return data when called. This can occur with both a [`channel`] and
/// a [`sync_channel`]. /// a [`sync_channel`].
/// ///
/// [`try_recv`]: struct.Receiver.html#method.try_recv /// [`try_recv`]: Receiver::try_recv
/// [`channel`]: fn.channel.html
/// [`sync_channel`]: fn.sync_channel.html
#[derive(PartialEq, Eq, Clone, Copy, Debug)] #[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub enum TryRecvError { pub enum TryRecvError {
@ -594,9 +570,7 @@ pub enum TryRecvError {
/// unable to return data when called. This can occur with both a [`channel`] and /// unable to return data when called. This can occur with both a [`channel`] and
/// a [`sync_channel`]. /// a [`sync_channel`].
/// ///
/// [`recv_timeout`]: struct.Receiver.html#method.recv_timeout /// [`recv_timeout`]: Receiver::recv_timeout
/// [`channel`]: fn.channel.html
/// [`sync_channel`]: fn.sync_channel.html
#[derive(PartialEq, Eq, Clone, Copy, Debug)] #[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[stable(feature = "mpsc_recv_timeout", since = "1.12.0")] #[stable(feature = "mpsc_recv_timeout", since = "1.12.0")]
pub enum RecvTimeoutError { pub enum RecvTimeoutError {
@ -613,7 +587,7 @@ pub enum RecvTimeoutError {
/// This enumeration is the list of the possible error outcomes for the /// This enumeration is the list of the possible error outcomes for the
/// [`try_send`] method. /// [`try_send`] method.
/// ///
/// [`try_send`]: struct.SyncSender.html#method.try_send /// [`try_send`]: SyncSender::try_send
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[derive(PartialEq, Eq, Clone, Copy)] #[derive(PartialEq, Eq, Clone, Copy)]
pub enum TrySendError<T> { pub enum TrySendError<T> {
@ -623,16 +597,11 @@ pub enum TrySendError<T> {
/// If this is a buffered channel, then the buffer is full at this time. If /// If this is a buffered channel, then the buffer is full at this time. If
/// this is not a buffered channel, then there is no [`Receiver`] available to /// this is not a buffered channel, then there is no [`Receiver`] available to
/// acquire the data. /// acquire the data.
///
/// [`sync_channel`]: fn.sync_channel.html
/// [`Receiver`]: struct.Receiver.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
Full(#[stable(feature = "rust1", since = "1.0.0")] T), Full(#[stable(feature = "rust1", since = "1.0.0")] T),
/// This [`sync_channel`]'s receiving half has disconnected, so the data could not be /// This [`sync_channel`]'s receiving half has disconnected, so the data could not be
/// sent. The data is returned back to the callee in this case. /// sent. The data is returned back to the callee in this case.
///
/// [`sync_channel`]: fn.sync_channel.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
Disconnected(#[stable(feature = "rust1", since = "1.0.0")] T), Disconnected(#[stable(feature = "rust1", since = "1.0.0")] T),
} }
@ -680,13 +649,8 @@ impl<T> UnsafeFlavor<T> for Receiver<T> {
/// [`Sender`] is disconnected while trying to [`recv`], the [`recv`] method will /// [`Sender`] is disconnected while trying to [`recv`], the [`recv`] method will
/// return a [`RecvError`]. /// return a [`RecvError`].
/// ///
/// [`send`]: struct.Sender.html#method.send /// [`send`]: Sender::send
/// [`recv`]: struct.Receiver.html#method.recv /// [`recv`]: Receiver::recv
/// [`Sender`]: struct.Sender.html
/// [`Receiver`]: struct.Receiver.html
/// [`sync_channel`]: fn.sync_channel.html
/// [`SendError`]: struct.SendError.html
/// [`RecvError`]: struct.RecvError.html
/// ///
/// # Examples /// # Examples
/// ///
@ -733,13 +697,8 @@ pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
/// [`SendError`]. Similarly, If the [`SyncSender`] is disconnected while trying /// [`SendError`]. Similarly, If the [`SyncSender`] is disconnected while trying
/// to [`recv`], the [`recv`] method will return a [`RecvError`]. /// to [`recv`], the [`recv`] method will return a [`RecvError`].
/// ///
/// [`channel`]: fn.channel.html /// [`send`]: SyncSender::send
/// [`send`]: struct.SyncSender.html#method.send /// [`recv`]: Receiver::recv
/// [`recv`]: struct.Receiver.html#method.recv
/// [`SyncSender`]: struct.SyncSender.html
/// [`Receiver`]: struct.Receiver.html
/// [`SendError`]: struct.SendError.html
/// [`RecvError`]: struct.RecvError.html
/// ///
/// # Examples /// # Examples
/// ///
@ -786,9 +745,6 @@ impl<T> Sender<T> {
/// will be received. It is possible for the corresponding receiver to /// will be received. It is possible for the corresponding receiver to
/// hang up immediately after this function returns [`Ok`]. /// hang up immediately after this function returns [`Ok`].
/// ///
/// [`Err`]: ../../../std/result/enum.Result.html#variant.Err
/// [`Ok`]: ../../../std/result/enum.Result.html#variant.Ok
///
/// This method will never block the current thread. /// This method will never block the current thread.
/// ///
/// # Examples /// # Examples
@ -933,9 +889,6 @@ impl<T> SyncSender<T> {
/// [`Receiver`] has disconnected and is no longer able to receive /// [`Receiver`] has disconnected and is no longer able to receive
/// information. /// information.
/// ///
/// [`Err`]: ../../../std/result/enum.Result.html#variant.Err
/// [`Receiver`]: ../../../std/sync/mpsc/struct.Receiver.html
///
/// # Examples /// # Examples
/// ///
/// ```rust /// ```rust
@ -971,7 +924,7 @@ impl<T> SyncSender<T> {
/// See [`send`] for notes about guarantees of whether the /// See [`send`] for notes about guarantees of whether the
/// receiver has received the data or not if this function is successful. /// receiver has received the data or not if this function is successful.
/// ///
/// [`send`]: ../../../std/sync/mpsc/struct.SyncSender.html#method.send /// [`send`]: Self::send
/// ///
/// # Examples /// # Examples
/// ///
@ -1059,7 +1012,7 @@ impl<T> Receiver<T> {
/// Compared with [`recv`], this function has two failure cases instead of one /// Compared with [`recv`], this function has two failure cases instead of one
/// (one for disconnection, one for an empty buffer). /// (one for disconnection, one for an empty buffer).
/// ///
/// [`recv`]: struct.Receiver.html#method.recv /// [`recv`]: Self::recv
/// ///
/// # Examples /// # Examples
/// ///
@ -1117,10 +1070,6 @@ impl<T> Receiver<T> {
/// However, since channels are buffered, messages sent before the disconnect /// However, since channels are buffered, messages sent before the disconnect
/// will still be properly received. /// will still be properly received.
/// ///
/// [`Sender`]: struct.Sender.html
/// [`SyncSender`]: struct.SyncSender.html
/// [`Err`]: ../../../std/result/enum.Result.html#variant.Err
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -1203,10 +1152,6 @@ impl<T> Receiver<T> {
/// However, since channels are buffered, messages sent before the disconnect /// However, since channels are buffered, messages sent before the disconnect
/// will still be properly received. /// will still be properly received.
/// ///
/// [`Sender`]: struct.Sender.html
/// [`SyncSender`]: struct.SyncSender.html
/// [`Err`]: ../../../std/result/enum.Result.html#variant.Err
///
/// # Known Issues /// # Known Issues
/// ///
/// There is currently a known issue (see [`#39364`]) that causes `recv_timeout` /// There is currently a known issue (see [`#39364`]) that causes `recv_timeout`
@ -1304,10 +1249,6 @@ impl<T> Receiver<T> {
/// However, since channels are buffered, messages sent before the disconnect /// However, since channels are buffered, messages sent before the disconnect
/// will still be properly received. /// will still be properly received.
/// ///
/// [`Sender`]: struct.Sender.html
/// [`SyncSender`]: struct.SyncSender.html
/// [`Err`]: ../../../std/result/enum.Result.html#variant.Err
///
/// # Examples /// # Examples
/// ///
/// Successfully receiving value before reaching deadline: /// Successfully receiving value before reaching deadline:
@ -1397,9 +1338,6 @@ impl<T> Receiver<T> {
/// Returns an iterator that will block waiting for messages, but never /// Returns an iterator that will block waiting for messages, but never
/// [`panic!`]. It will return [`None`] when the channel has hung up. /// [`panic!`]. It will return [`None`] when the channel has hung up.
/// ///
/// [`panic!`]: ../../../std/macro.panic.html
/// [`None`]: ../../../std/option/enum.Option.html#variant.None
///
/// # Examples /// # Examples
/// ///
/// ```rust /// ```rust
@ -1430,8 +1368,6 @@ impl<T> Receiver<T> {
/// channel has hung up. The iterator will never [`panic!`] or block the /// channel has hung up. The iterator will never [`panic!`] or block the
/// user by waiting for values. /// user by waiting for values.
/// ///
/// [`panic!`]: ../../../std/macro.panic.html
///
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run

View file

@ -33,13 +33,12 @@ use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
/// the guard that would have otherwise been returned on a successful lock. This /// the guard that would have otherwise been returned on a successful lock. This
/// allows access to the data, despite the lock being poisoned. /// allows access to the data, despite the lock being poisoned.
/// ///
/// [`new`]: #method.new /// [`new`]: Self::new
/// [`lock`]: #method.lock /// [`lock`]: Self::lock
/// [`try_lock`]: #method.try_lock /// [`try_lock`]: Self::try_lock
/// [`Result`]: ../../std/result/enum.Result.html /// [`unwrap()`]: Result::unwrap
/// [`unwrap()`]: ../../std/result/enum.Result.html#method.unwrap /// [`PoisonError`]: super::PoisonError
/// [`PoisonError`]: ../../std/sync/struct.PoisonError.html /// [`into_inner`]: super::PoisonError::into_inner
/// [`into_inner`]: ../../std/sync/struct.PoisonError.html#method.into_inner
/// ///
/// # Examples /// # Examples
/// ///
@ -190,11 +189,8 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> {}
/// This structure is created by the [`lock`] and [`try_lock`] methods on /// This structure is created by the [`lock`] and [`try_lock`] methods on
/// [`Mutex`]. /// [`Mutex`].
/// ///
/// [`Deref`]: ../../std/ops/trait.Deref.html /// [`lock`]: Mutex::lock
/// [`DerefMut`]: ../../std/ops/trait.DerefMut.html /// [`try_lock`]: Mutex::try_lock
/// [`lock`]: struct.Mutex.html#method.lock
/// [`try_lock`]: struct.Mutex.html#method.try_lock
/// [`Mutex`]: struct.Mutex.html
#[must_use = "if unused the Mutex will immediately unlock"] #[must_use = "if unused the Mutex will immediately unlock"]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct MutexGuard<'a, T: ?Sized + 'a> { pub struct MutexGuard<'a, T: ?Sized + 'a> {
@ -289,8 +285,6 @@ impl<T: ?Sized> Mutex<T> {
/// this call will return failure if the mutex would otherwise be /// this call will return failure if the mutex would otherwise be
/// acquired. /// acquired.
/// ///
/// [`Err`]: ../../std/result/enum.Result.html#variant.Err
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -432,8 +426,6 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex<T> {
impl<T> From<T> for Mutex<T> { impl<T> From<T> for Mutex<T> {
/// Creates a new mutex in an unlocked state ready for use. /// Creates a new mutex in an unlocked state ready for use.
/// This is equivalent to [`Mutex::new`]. /// This is equivalent to [`Mutex::new`].
///
/// [`Mutex::new`]: ../../std/sync/struct.Mutex.html#method.new
fn from(t: T) -> Self { fn from(t: T) -> Self {
Mutex::new(t) Mutex::new(t)
} }

View file

@ -58,11 +58,7 @@ use crate::sys_common::rwlock as sys;
/// } // write lock is dropped here /// } // write lock is dropped here
/// ``` /// ```
/// ///
/// [`Deref`]: ../../std/ops/trait.Deref.html /// [`Mutex`]: super::Mutex
/// [`DerefMut`]: ../../std/ops/trait.DerefMut.html
/// [`Send`]: ../../std/marker/trait.Send.html
/// [`Sync`]: ../../std/marker/trait.Sync.html
/// [`Mutex`]: struct.Mutex.html
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLock<T: ?Sized> { pub struct RwLock<T: ?Sized> {
inner: Box<sys::RWLock>, inner: Box<sys::RWLock>,
@ -81,9 +77,8 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
/// This structure is created by the [`read`] and [`try_read`] methods on /// This structure is created by the [`read`] and [`try_read`] methods on
/// [`RwLock`]. /// [`RwLock`].
/// ///
/// [`read`]: struct.RwLock.html#method.read /// [`read`]: RwLock::read
/// [`try_read`]: struct.RwLock.html#method.try_read /// [`try_read`]: RwLock::try_read
/// [`RwLock`]: struct.RwLock.html
#[must_use = "if unused the RwLock will immediately unlock"] #[must_use = "if unused the RwLock will immediately unlock"]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
@ -102,9 +97,8 @@ unsafe impl<T: ?Sized + Sync> Sync for RwLockReadGuard<'_, T> {}
/// This structure is created by the [`write`] and [`try_write`] methods /// This structure is created by the [`write`] and [`try_write`] methods
/// on [`RwLock`]. /// on [`RwLock`].
/// ///
/// [`write`]: struct.RwLock.html#method.write /// [`write`]: RwLock::write
/// [`try_write`]: struct.RwLock.html#method.try_write /// [`try_write`]: RwLock::try_write
/// [`RwLock`]: struct.RwLock.html
#[must_use = "if unused the RwLock will immediately unlock"] #[must_use = "if unused the RwLock will immediately unlock"]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> { pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {
@ -456,8 +450,6 @@ impl<T: Default> Default for RwLock<T> {
impl<T> From<T> for RwLock<T> { impl<T> From<T> for RwLock<T> {
/// Creates a new instance of an `RwLock<T>` which is unlocked. /// Creates a new instance of an `RwLock<T>` which is unlocked.
/// This is equivalent to [`RwLock::new`]. /// This is equivalent to [`RwLock::new`].
///
/// [`RwLock::new`]: ../../std/sync/struct.RwLock.html#method.new
fn from(t: T) -> Self { fn from(t: T) -> Self {
RwLock::new(t) RwLock::new(t)
} }