doc: clarify Mutex::try_lock, etc. errors
Clarify error returns from Mutex::try_lock, RwLock::try_read, RwLock::try_write to make it more obvious that both poisoning and the lock being already locked are possible errors.
This commit is contained in:
parent
99e3aef020
commit
e5873660fc
2 changed files with 28 additions and 9 deletions
|
@ -294,8 +294,14 @@ impl<T: ?Sized> Mutex<T> {
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// If another user of this mutex panicked while holding the mutex, then
|
/// If another user of this mutex panicked while holding the mutex, then
|
||||||
/// this call will return an error if the mutex would otherwise be
|
/// this call will return the error [`Poisoned`] if the mutex would
|
||||||
/// acquired.
|
/// otherwise be acquired.
|
||||||
|
///
|
||||||
|
/// If the mutex could not be acquired because it is already locked, then
|
||||||
|
/// this call will return [`WouldBlock`].
|
||||||
|
///
|
||||||
|
/// [`Poisoned`]: TryLockError::Poisoned
|
||||||
|
/// [`WouldBlock`]: TryLockError::WouldBlock
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|
|
@ -199,11 +199,17 @@ impl<T: ?Sized> RwLock<T> {
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// This function will return an error if the RwLock is poisoned. An RwLock
|
/// This function will return the error [`Poisoned`] if the RwLock is poisoned.
|
||||||
/// is poisoned whenever a writer panics while holding an exclusive lock. An
|
/// An RwLock is poisoned whenever a writer panics while holding an exclusive
|
||||||
/// error will only be returned if the lock would have otherwise been
|
/// lock. `Poisoned` will only be returned if the lock would have otherwise been
|
||||||
/// acquired.
|
/// acquired.
|
||||||
///
|
///
|
||||||
|
/// This function will return the error [`WouldBlock`] if the RwLock could not
|
||||||
|
/// be acquired because it was already locked exclusively.
|
||||||
|
///
|
||||||
|
/// [`Poisoned`]: TryLockError::Poisoned
|
||||||
|
/// [`WouldBlock`]: TryLockError::WouldBlock
|
||||||
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -281,10 +287,17 @@ impl<T: ?Sized> RwLock<T> {
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// This function will return an error if the RwLock is poisoned. An RwLock
|
/// This function will return the error [`Poisoned`] if the RwLock is
|
||||||
/// is poisoned whenever a writer panics while holding an exclusive lock. An
|
/// poisoned. An RwLock is poisoned whenever a writer panics while holding
|
||||||
/// error will only be returned if the lock would have otherwise been
|
/// an exclusive lock. `Poisoned` will only be returned if the lock would have
|
||||||
/// acquired.
|
/// otherwise been acquired.
|
||||||
|
///
|
||||||
|
/// This function will return the error [`WouldBlock`] if the RwLock could not
|
||||||
|
/// be acquired because it was already locked exclusively.
|
||||||
|
///
|
||||||
|
/// [`Poisoned`]: TryLockError::Poisoned
|
||||||
|
/// [`WouldBlock`]: TryLockError::WouldBlock
|
||||||
|
///
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Reference in a new issue