@@ -25,6 +25,7 @@ use std::str;
25
25
26
26
struct A ;
27
27
struct B ;
28
+ struct C ;
28
29
29
30
impl fmt:: Signed for A {
30
31
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
@@ -36,6 +37,11 @@ impl fmt::Signed for B {
36
37
f. write ( "adios" . as_bytes ( ) )
37
38
}
38
39
}
40
+ impl fmt:: Show for C {
41
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
42
+ f. pad_integral ( true , "☃" , "123" . as_bytes ( ) )
43
+ }
44
+ }
39
45
40
46
macro_rules! t( ( $a: expr, $b: expr) => { assert_eq!( $a. as_slice( ) , $b) } )
41
47
@@ -81,13 +87,15 @@ pub fn main() {
81
87
t ! ( format!( "{} {0}" , "a" ) , "a a" ) ;
82
88
t ! ( format!( "{foo_bar}" , foo_bar=1 i) , "1" ) ;
83
89
t ! ( format!( "{:d}" , 5 i + 5 i) , "10" ) ;
90
+ t ! ( format!( "{:#4}" , C ) , "☃123" ) ;
84
91
85
92
let a: & fmt:: Show = & 1 i;
86
93
t ! ( format!( "{}" , a) , "1" ) ;
87
94
88
95
// Formatting strings and their arguments
89
96
t ! ( format!( "{:s}" , "a" ) , "a" ) ;
90
97
t ! ( format!( "{:4s}" , "a" ) , "a " ) ;
98
+ t ! ( format!( "{:4s}" , "☃" ) , "☃ " ) ;
91
99
t ! ( format!( "{:>4s}" , "a" ) , " a" ) ;
92
100
t ! ( format!( "{:<4s}" , "a" ) , "a " ) ;
93
101
t ! ( format!( "{:^5s}" , "a" ) , " a " ) ;
0 commit comments