We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
{:s}
1 parent 680eb71 commit 1092744Copy full SHA for 1092744
src/libstd/fmt/mod.rs
@@ -726,9 +726,9 @@ impl Bool for bool {
726
}
727
728
729
-impl<'self> String for &'self str {
730
- fn fmt(s: & &'self str, f: &mut Formatter) {
731
- f.pad(*s);
+impl<'self, T: str::Str> String for T {
+ fn fmt(s: &T, f: &mut Formatter) {
+ f.pad(s.as_slice());
732
733
734
src/test/run-pass/ifmt.rs
@@ -45,6 +45,8 @@ pub fn main() {
45
t!(ifmt!("{:x}", 10u), "a");
46
t!(ifmt!("{:X}", 10u), "A");
47
t!(ifmt!("{:s}", "foo"), "foo");
48
+ t!(ifmt!("{:s}", ~"foo"), "foo");
49
+ t!(ifmt!("{:s}", @"foo"), "foo");
50
t!(ifmt!("{:p}", 0x1234 as *int), "0x1234");
51
t!(ifmt!("{:p}", 0x1234 as *mut int), "0x1234");
52
t!(ifmt!("{:d}", A), "aloha");
0 commit comments