diff options
| author | Botahamec <botahamec@outlook.com> | 2024-05-22 21:02:37 -0400 |
|---|---|---|
| committer | Botahamec <botahamec@outlook.com> | 2024-05-22 21:02:37 -0400 |
| commit | fa39064fe2f3399d27762a23c54d4703d00bd199 (patch) | |
| tree | a6da67d0f7808fdecf56568e1741ec3189c9a24f /src/rwlock/rwlock.rs | |
| parent | 878f4fae4d3c6e64ab3824bf3fc012fbb5293a21 (diff) | |
must use
Diffstat (limited to 'src/rwlock/rwlock.rs')
| -rw-r--r-- | src/rwlock/rwlock.rs | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/src/rwlock/rwlock.rs b/src/rwlock/rwlock.rs index 9a7590a..00ce7d0 100644 --- a/src/rwlock/rwlock.rs +++ b/src/rwlock/rwlock.rs @@ -76,7 +76,7 @@ impl<T, R: RawRwLock> From<T> for RwLock<T, R> { impl<T: ?Sized, R> AsMut<T> for RwLock<T, R> { fn as_mut(&mut self) -> &mut T { - self.get_mut() + self.data.get_mut() } } @@ -96,32 +96,12 @@ impl<T, R> RwLock<T, R> { /// } /// assert_eq!(lock.into_inner(), "modified"); /// ``` + #[must_use] pub fn into_inner(self) -> T { self.data.into_inner() } } -impl<T: ?Sized, R> RwLock<T, R> { - /// Returns a mutable reference to the underlying data. - /// - /// Since this call borrows the `RwLock` mutably, no actual locking needs - /// to take place. The mutable borrow statically guarantees no locks exist. - /// - /// # Examples - /// - /// ``` - /// use happylock::{RwLock, ThreadKey}; - /// - /// let key = ThreadKey::get().unwrap(); - /// let mut lock = RwLock::new(0); - /// *lock.get_mut() = 10; - /// assert_eq!(*lock.read(key), 10); - /// ``` - pub fn get_mut(&mut self) -> &mut T { - self.data.get_mut() - } -} - impl<T: ?Sized, R: RawRwLock> RwLock<T, R> { /// Locks this `RwLock` with shared read access, blocking the current /// thread until it can be acquired. |
