summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMicha White <botahamec@outlook.com>2024-05-26 22:18:24 -0400
committerMicha White <botahamec@outlook.com>2024-05-26 22:18:24 -0400
commitd5496c35c1c62492516baca30043c3cbec1a718c (patch)
tree9e3f354bc288e2d32e6703916192822f202ad6c4 /src
parentfd4ee65a78ecbf376d99377a367137b0b8cdad41 (diff)
impl Display and Debug for write guards
Diffstat (limited to 'src')
-rw-r--r--src/rwlock/write_guard.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/rwlock/write_guard.rs b/src/rwlock/write_guard.rs
index 5b41c99..bbf747a 100644
--- a/src/rwlock/write_guard.rs
+++ b/src/rwlock/write_guard.rs
@@ -7,6 +7,18 @@ use crate::key::Keyable;
use super::{RwLock, RwLockWriteGuard, RwLockWriteRef};
+impl<'a, T: Debug + ?Sized + 'a, R: RawRwLock> Debug for RwLockWriteRef<'a, T, R> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ Debug::fmt(&**self, f)
+ }
+}
+
+impl<'a, T: Display + ?Sized + 'a, R: RawRwLock> Display for RwLockWriteRef<'a, T, R> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ Display::fmt(&**self, f)
+ }
+}
+
impl<'a, T: ?Sized + 'a, R: RawRwLock> Deref for RwLockWriteRef<'a, T, R> {
type Target = T;
@@ -56,6 +68,22 @@ impl<'a, T: ?Sized + 'a, R: RawRwLock> RwLockWriteRef<'a, T, R> {
}
}
+impl<'a, 'key, T: Debug + ?Sized + 'a, Key: Keyable + 'key, R: RawRwLock> Debug
+ for RwLockWriteGuard<'a, 'key, T, Key, R>
+{
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ Debug::fmt(&**self, f)
+ }
+}
+
+impl<'a, 'key, T: Display + ?Sized + 'a, Key: Keyable + 'key, R: RawRwLock> Display
+ for RwLockWriteGuard<'a, 'key, T, Key, R>
+{
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ Display::fmt(&**self, f)
+ }
+}
+
impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> Deref
for RwLockWriteGuard<'a, 'key, T, Key, R>
{
@@ -106,3 +134,5 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock>
}
unsafe impl<'a, T: ?Sized + Sync + 'a, R: RawRwLock + Sync + 'a> Sync for RwLockWriteRef<'a, T, R> {}
+
+// TODO implement display and debug here