Implement {:s}
for ~str and @str as well
This commit is contained in:
parent
680eb71564
commit
109274426a
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user