Skip to content

Commit b36c978

Browse files
committed
alloc: impl fmt::Pointer for Box<T>
via Unique<T>
1 parent 3f3bcdc commit b36c978

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/liballoc/boxed.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ impl<T: fmt::Debug + ?Sized> fmt::Debug for Box<T> {
275275
}
276276
}
277277

278+
#[stable(feature = "rust1", since = "1.0.0")]
279+
impl<T> fmt::Pointer for Box<T> {
280+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
281+
fmt::Pointer::fmt(&*self, f)
282+
}
283+
}
284+
278285
#[stable(feature = "rust1", since = "1.0.0")]
279286
impl<T: ?Sized> Deref for Box<T> {
280287
type Target = T;

src/libcore/ptr.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ use mem;
9494
use clone::Clone;
9595
use intrinsics;
9696
use ops::Deref;
97+
use core::fmt;
9798
use option::Option::{self, Some, None};
9899
use marker::{PhantomData, Send, Sized, Sync};
99100
use nonzero::NonZero;
@@ -570,3 +571,10 @@ impl<T:?Sized> Deref for Unique<T> {
570571
unsafe { mem::transmute(&*self.pointer) }
571572
}
572573
}
574+
575+
#[stable(feature = "rust1", since = "1.0.0")]
576+
impl<T> fmt::Pointer for Unique<T> {
577+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
578+
fmt::Pointer::fmt(&*self.pointer, f)
579+
}
580+
}

0 commit comments

Comments
 (0)