summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2024-09-27 20:01:25 -0400
committerBotahamec <botahamec@outlook.com>2024-09-27 20:01:25 -0400
commit654a46976347e665588e65afe86bbea6a2b6098c (patch)
tree557e487db9d47aaadc6f77c45fbbcdefe338d1e1 /src
parent2376ccee97c99d5c47c09fcf308a97aaf785a29e (diff)
Document LockableAsMut and LockableIntoInner
Diffstat (limited to 'src')
-rw-r--r--src/lockable.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lockable.rs b/src/lockable.rs
index 6eced32..e32fccd 100644
--- a/src/lockable.rs
+++ b/src/lockable.rs
@@ -151,15 +151,39 @@ pub unsafe trait Lockable {
unsafe fn read_guard(&self) -> Self::ReadGuard<'_>;
}
+/// A trait which indicates that `into_inner` is a valid operation for a
+/// [`Lockable`].
+///
+/// This is used for types like [`Poisonable`] to access the inner value of a
+/// lock. [`Poisonable::into_inner`] calls [`LockableIntoInner::into_inner`] to
+/// return a mutable reference of the inner value. This isn't implemented for
+/// some `Lockable`s, such as `&[T]`.
+///
+/// [`Poisonable`]: `crate::Poisonable`
+/// [`Poisonable::into_inner`]: `crate::poisonable::Poisonable::into_inner`
pub trait LockableIntoInner: Lockable {
+ /// The inner type that is behind the lock
type Inner;
+ /// Consumes the lock, returning the underlying the lock.
fn into_inner(self) -> Self::Inner;
}
+/// A trait which indicates that `as_mut` is a valid operation for a
+/// [`Lockable`].
+///
+/// This is used for types like [`Poisonable`] to access the inner value of a
+/// lock. [`Poisonable::get_mut`] calls [`LockableAsMut::as_mut`] to return a
+/// mutable reference of the inner value. This isn't implemented for some
+/// `Lockable`s, such as `&[T]`.
+///
+/// [`Poisonable`]: `crate::Poisonable`
+/// [`Poisonable::get_mut`]: `crate::poisonable::Poisonable::get_mut`
pub trait LockableAsMut: Lockable {
+ /// The inner type that is behind the lock
type Inner;
+ /// Returns a mutable reference to the underlying data.
fn as_mut(&mut self) -> &mut Self::Inner;
}