about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libstd/fmt/mod.rs6
-rw-r--r--src/test/run-pass/ifmt.rs2
2 files changed, 5 insertions, 3 deletions
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs
index 70ec5d93199..cd3f85e83fa 100644
--- a/src/libstd/fmt/mod.rs
+++ b/src/libstd/fmt/mod.rs
@@ -726,9 +726,9 @@ impl Bool for bool {
     }
 }
 
-impl<'self> String for &'self str {
-    fn fmt(s: & &'self str, f: &mut Formatter) {
-        f.pad(*s);
+impl<'self, T: str::Str> String for T {
+    fn fmt(s: &T, f: &mut Formatter) {
+        f.pad(s.as_slice());
     }
 }
 
diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs
index a0d3eb7d803..8076c081e87 100644
--- a/src/test/run-pass/ifmt.rs
+++ b/src/test/run-pass/ifmt.rs
@@ -45,6 +45,8 @@ pub fn main() {
     t!(ifmt!("{:x}", 10u), "a");
     t!(ifmt!("{:X}", 10u), "A");
     t!(ifmt!("{:s}", "foo"), "foo");
+    t!(ifmt!("{:s}", ~"foo"), "foo");
+    t!(ifmt!("{:s}", @"foo"), "foo");
     t!(ifmt!("{:p}", 0x1234 as *int), "0x1234");
     t!(ifmt!("{:p}", 0x1234 as *mut int), "0x1234");
     t!(ifmt!("{:d}", A), "aloha");