summaryrefslogtreecommitdiff
path: root/src/rwlock/write_guard.rs
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2024-05-22 15:53:49 -0400
committerBotahamec <botahamec@outlook.com>2024-05-22 15:53:49 -0400
commitebbe3cfce28914d776f3e5f89894fab50911c57e (patch)
tree7ecb7357b9decbe37817eea57e51346aaf055438 /src/rwlock/write_guard.rs
parentf5cb25b01f265c9247bd0cb8955addcbaa94fea2 (diff)
Implemented necessary traits
Diffstat (limited to 'src/rwlock/write_guard.rs')
-rw-r--r--src/rwlock/write_guard.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/rwlock/write_guard.rs b/src/rwlock/write_guard.rs
index 16b474e..c8dd58b 100644
--- a/src/rwlock/write_guard.rs
+++ b/src/rwlock/write_guard.rs
@@ -27,6 +27,18 @@ impl<'a, T: ?Sized + 'a, R: RawRwLock> DerefMut for RwLockWriteRef<'a, T, R> {
}
}
+impl<'a, T: ?Sized + 'a, R: RawRwLock> AsRef<T> for RwLockWriteRef<'a, T, R> {
+ fn as_ref(&self) -> &T {
+ self
+ }
+}
+
+impl<'a, T: ?Sized + 'a, R: RawRwLock> AsMut<T> for RwLockWriteRef<'a, T, R> {
+ fn as_mut(&mut self) -> &mut T {
+ self
+ }
+}
+
impl<'a, T: ?Sized + 'a, R: RawRwLock> Drop for RwLockWriteRef<'a, T, R> {
fn drop(&mut self) {
// safety: this guard is being destroyed, so the data cannot be
@@ -59,6 +71,22 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> DerefMut
}
}
+impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> AsRef<T>
+ for RwLockWriteGuard<'a, 'key, T, Key, R>
+{
+ fn as_ref(&self) -> &T {
+ self
+ }
+}
+
+impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> AsMut<T>
+ for RwLockWriteGuard<'a, 'key, T, Key, R>
+{
+ fn as_mut(&mut self) -> &mut T {
+ self
+ }
+}
+
impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock>
RwLockWriteGuard<'a, 'key, T, Key, R>
{