diff options
| author | Sean McArthur <sean.monstar@gmail.com> | 2014-12-20 00:09:35 -0800 |
|---|---|---|
| committer | Sean McArthur <sean.monstar@gmail.com> | 2015-01-06 14:49:42 -0800 |
| commit | 44440e5c18a1dbcc9685866ffffe00c508929079 (patch) | |
| tree | b66c50cd1e471dc0e37b8a0db2cf7f8f28fbac5f /src/liballoc/boxed.rs | |
| parent | 8efd9901b628d687d11a4d0ccc153553b38ada49 (diff) | |
| download | rust-44440e5c18a1dbcc9685866ffffe00c508929079.tar.gz rust-44440e5c18a1dbcc9685866ffffe00c508929079.zip | |
core: split into fmt::Show and fmt::String
fmt::Show is for debugging, and can and should be implemented for
all public types. This trait is used with `{:?}` syntax. There still
exists #[derive(Show)].
fmt::String is for types that faithfully be represented as a String.
Because of this, there is no way to derive fmt::String, all
implementations must be purposeful. It is used by the default format
syntax, `{}`.
This will break most instances of `{}`, since that now requires the type
to impl fmt::String. In most cases, replacing `{}` with `{:?}` is the
correct fix. Types that were being printed specifically for users should
receive a fmt::String implementation to fix this.
Part of #20013
[breaking-change]
Diffstat (limited to 'src/liballoc/boxed.rs')
| -rw-r--r-- | src/liballoc/boxed.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 6df8bb5f7aa..b4eb71df167 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -145,7 +145,13 @@ impl BoxAny for Box<Any> { impl<T: ?Sized + fmt::Show> fmt::Show for Box<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - (**self).fmt(f) + write!(f, "Box({:?})", &**self) + } +} + +impl<Sized? T: fmt::String> fmt::String for Box<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(&**self, f) } } |
