Skip to content

Commit d72827a

Browse files
committed
Add missing fmt impls
1 parent df0f28b commit d72827a

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1010

1111
- `std::sync` wrappers now no longer incorrectly require `T: Sized`
1212

13+
- Added missing `Display` and `Debug` implementations to `RwLock(Read|Write)Guard`.
14+
1315
## [0.3.1]
1416

1517
### Added

src/stdsync/tracing.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ pub struct Mutex<T: ?Sized> {
3434
///
3535
/// Refer to the [crate-level][`crate`] documentation for the differences between this struct and
3636
/// the one it wraps.
37-
#[derive(Debug)]
3837
pub struct MutexGuard<'a, T: ?Sized> {
3938
inner: sync::MutexGuard<'a, T>,
4039
_mutex: BorrowedMutex<'a>,
@@ -148,18 +147,28 @@ impl<T> From<T> for Mutex<T> {
148147
impl<T: ?Sized> Deref for MutexGuard<'_, T> {
149148
type Target = T;
150149

150+
#[inline]
151151
fn deref(&self) -> &Self::Target {
152152
&self.inner
153153
}
154154
}
155155

156156
impl<T: ?Sized> DerefMut for MutexGuard<'_, T> {
157+
#[inline]
157158
fn deref_mut(&mut self) -> &mut Self::Target {
158159
&mut self.inner
159160
}
160161
}
161162

163+
impl<T: ?Sized + fmt::Debug> fmt::Debug for MutexGuard<'_, T> {
164+
#[inline]
165+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
166+
self.inner.fmt(f)
167+
}
168+
}
169+
162170
impl<T: fmt::Display + ?Sized> fmt::Display for MutexGuard<'_, T> {
171+
#[inline]
163172
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
164173
self.inner.fmt(f)
165174
}
@@ -287,7 +296,6 @@ pub struct RwLock<T: ?Sized> {
287296
/// Hybrid wrapper for both [`std::sync::RwLockReadGuard`] and [`std::sync::RwLockWriteGuard`].
288297
///
289298
/// Please refer to [`RwLockReadGuard`] and [`RwLockWriteGuard`] for usable types.
290-
#[derive(Debug)]
291299
pub struct TracingRwLockGuard<'a, L> {
292300
inner: L,
293301
_mutex: BorrowedMutex<'a>,
@@ -411,6 +419,7 @@ where
411419
{
412420
type Target = T;
413421

422+
#[inline]
414423
fn deref(&self) -> &Self::Target {
415424
self.inner.deref()
416425
}
@@ -421,11 +430,32 @@ where
421430
T: ?Sized,
422431
L: Deref<Target = T> + DerefMut,
423432
{
433+
#[inline]
424434
fn deref_mut(&mut self) -> &mut Self::Target {
425435
self.inner.deref_mut()
426436
}
427437
}
428438

439+
impl<L> fmt::Debug for TracingRwLockGuard<'_, L>
440+
where
441+
L: fmt::Debug,
442+
{
443+
#[inline]
444+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
445+
self.inner.fmt(f)
446+
}
447+
}
448+
449+
impl<L> fmt::Display for TracingRwLockGuard<'_, L>
450+
where
451+
L: fmt::Display,
452+
{
453+
#[inline]
454+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
455+
self.inner.fmt(f)
456+
}
457+
}
458+
429459
/// Wrapper around [`std::sync::Once`].
430460
///
431461
/// Refer to the [crate-level][`crate`] documentaiton for the differences between this struct

0 commit comments

Comments
 (0)