about summary refs log tree commit diff
path: root/src/libcore/macros.rs
diff options
context:
space:
mode:
authorSean McArthur <sean.monstar@gmail.com>2014-12-20 00:09:35 -0800
committerSean McArthur <sean.monstar@gmail.com>2015-01-06 14:49:42 -0800
commit44440e5c18a1dbcc9685866ffffe00c508929079 (patch)
treeb66c50cd1e471dc0e37b8a0db2cf7f8f28fbac5f /src/libcore/macros.rs
parent8efd9901b628d687d11a4d0ccc153553b38ada49 (diff)
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/libcore/macros.rs')
-rw-r--r--src/libcore/macros.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs
index a579f9db416..99e49cc21ed 100644
--- a/src/libcore/macros.rs
+++ b/src/libcore/macros.rs
@@ -83,7 +83,7 @@ macro_rules! assert_eq {
                 if !((*left_val == *right_val) &&
                      (*right_val == *left_val)) {
                     panic!("assertion failed: `(left == right) && (right == left)` \
-                           (left: `{}`, right: `{}`)", *left_val, *right_val)
+                           (left: `{:?}`, right: `{:?}`)", *left_val, *right_val)
                 }
             }
         }