Skip to content

Commit 434cb2f

Browse files
bors[bot]Frawst
and
Frawst
authored
Merge #47
47: fmt::Debug and fmt::Pointer implementations for Gc<T> r=jacob-hughes a=Frawstcrabs Co-authored-by: Frawst <[email protected]>
2 parents 4d1fd5c + 6c2b179 commit 434cb2f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/gc.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn gc_init() {
3838
///
3939
/// `Gc<T>` automatically dereferences to `T` (via the `Deref` trait), so
4040
/// you can call `T`'s methods on a value of type `Gc<T>`.
41-
#[derive(PartialEq, Eq, Debug)]
41+
#[derive(PartialEq, Eq)]
4242
pub struct Gc<T: ?Sized + Send + Sync> {
4343
ptr: NonNull<GcBox<T>>,
4444
_phantom: PhantomData<T>,
@@ -176,6 +176,18 @@ impl<T: ?Sized + fmt::Display + Send + Sync> fmt::Display for Gc<T> {
176176
}
177177
}
178178

179+
impl<T: ?Sized + fmt::Debug + Send + Sync> fmt::Debug for Gc<T> {
180+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
181+
fmt::Debug::fmt(&**self, f)
182+
}
183+
}
184+
185+
impl<T: ?Sized + Send + Sync> fmt::Pointer for Gc<T> {
186+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
187+
fmt::Pointer::fmt(&(&**self as *const T), f)
188+
}
189+
}
190+
179191
/// A `GcBox` is a 0-cost wrapper which allows a single `Drop` implementation
180192
/// while also permitting multiple, copyable `Gc` references. The `drop` method
181193
/// on `GcBox` acts as a guard, preventing the destructors on its contents from

0 commit comments

Comments
 (0)