diff --git a/CHANGELOG.md b/CHANGELOG.md index 636bafb..331f6bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - `std::sync` wrappers now no longer incorrectly require `T: Sized` +- Added missing `Display` and `Debug` implementations to `RwLock(Read|Write)Guard`. + ## [0.3.1] ### Added diff --git a/src/stdsync/tracing.rs b/src/stdsync/tracing.rs index ccbaa6c..e02d55a 100644 --- a/src/stdsync/tracing.rs +++ b/src/stdsync/tracing.rs @@ -34,7 +34,6 @@ pub struct Mutex { /// /// Refer to the [crate-level][`crate`] documentation for the differences between this struct and /// the one it wraps. -#[derive(Debug)] pub struct MutexGuard<'a, T: ?Sized> { inner: sync::MutexGuard<'a, T>, _mutex: BorrowedMutex<'a>, @@ -148,18 +147,28 @@ impl From for Mutex { impl Deref for MutexGuard<'_, T> { type Target = T; + #[inline] fn deref(&self) -> &Self::Target { &self.inner } } impl DerefMut for MutexGuard<'_, T> { + #[inline] fn deref_mut(&mut self) -> &mut Self::Target { &mut self.inner } } +impl fmt::Debug for MutexGuard<'_, T> { + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.inner.fmt(f) + } +} + impl fmt::Display for MutexGuard<'_, T> { + #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.inner.fmt(f) } @@ -287,7 +296,6 @@ pub struct RwLock { /// Hybrid wrapper for both [`std::sync::RwLockReadGuard`] and [`std::sync::RwLockWriteGuard`]. /// /// Please refer to [`RwLockReadGuard`] and [`RwLockWriteGuard`] for usable types. -#[derive(Debug)] pub struct TracingRwLockGuard<'a, L> { inner: L, _mutex: BorrowedMutex<'a>, @@ -411,6 +419,7 @@ where { type Target = T; + #[inline] fn deref(&self) -> &Self::Target { self.inner.deref() } @@ -421,11 +430,32 @@ where T: ?Sized, L: Deref + DerefMut, { + #[inline] fn deref_mut(&mut self) -> &mut Self::Target { self.inner.deref_mut() } } +impl fmt::Debug for TracingRwLockGuard<'_, L> +where + L: fmt::Debug, +{ + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.inner.fmt(f) + } +} + +impl fmt::Display for TracingRwLockGuard<'_, L> +where + L: fmt::Display, +{ + #[inline] + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + self.inner.fmt(f) + } +} + /// Wrapper around [`std::sync::Once`]. /// /// Refer to the [crate-level][`crate`] documentaiton for the differences between this struct