summaryrefslogtreecommitdiff
path: root/src/mutex/guard.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mutex/guard.rs')
-rw-r--r--src/mutex/guard.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mutex/guard.rs b/src/mutex/guard.rs
index 9e8e2e6..f9324ad 100644
--- a/src/mutex/guard.rs
+++ b/src/mutex/guard.rs
@@ -8,6 +8,9 @@ use crate::key::Keyable;
use super::{Mutex, MutexGuard, MutexRef};
+// This makes things slightly easier because now you can use
+// `println!("{guard}")` instead of `println!("{}", *guard)`. I wonder if I
+// should implement some other standard library traits like this too?
impl<'a, T: Debug + ?Sized + 'a, R: RawMutex> Debug for MutexRef<'a, T, R> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Debug::fmt(&**self, f)
@@ -63,11 +66,18 @@ impl<'a, T: ?Sized + 'a, R: RawMutex> AsMut<T> for MutexRef<'a, T, R> {
impl<'a, T: ?Sized + 'a, R: RawMutex> MutexRef<'a, T, R> {
/// Creates a reference to the underlying data of a mutex without
/// attempting to lock it or take ownership of the key.
+
+ // This might be useful to export, because it makes it easier to express
+ // the concept of: "Get the data out the mutex but don't lock it or take
+ // the key". But it's also quite dangerous to drop.
pub(crate) unsafe fn new(mutex: &'a Mutex<T, R>) -> Self {
Self(mutex, PhantomData)
}
}
+// it's kinda annoying to re-implement some of this stuff on guards
+// there's nothing i can do about that
+
impl<'a, 'key, T: Debug + ?Sized + 'a, Key: Keyable + 'key, R: RawMutex> Debug
for MutexGuard<'a, 'key, T, Key, R>
{