@@ -25,6 +25,7 @@ use std::str;
2525
2626struct A ;
2727struct B ;
28+ struct C ;
2829
2930impl fmt:: Signed for A {
3031 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
@@ -36,6 +37,11 @@ impl fmt::Signed for B {
3637 f. write ( "adios" . as_bytes ( ) )
3738 }
3839}
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+ }
3945
4046macro_rules! t( ( $a: expr, $b: expr) => { assert_eq!( $a. as_slice( ) , $b) } )
4147
@@ -81,13 +87,15 @@ pub fn main() {
8187 t ! ( format!( "{} {0}" , "a" ) , "a a" ) ;
8288 t ! ( format!( "{foo_bar}" , foo_bar=1 i) , "1" ) ;
8389 t ! ( format!( "{:d}" , 5 i + 5 i) , "10" ) ;
90+ t ! ( format!( "{:#4}" , C ) , "☃123" ) ;
8491
8592 let a: & fmt:: Show = & 1 i;
8693 t ! ( format!( "{}" , a) , "1" ) ;
8794
8895 // Formatting strings and their arguments
8996 t ! ( format!( "{:s}" , "a" ) , "a" ) ;
9097 t ! ( format!( "{:4s}" , "a" ) , "a " ) ;
98+ t ! ( format!( "{:4s}" , "☃" ) , "☃ " ) ;
9199 t ! ( format!( "{:>4s}" , "a" ) , " a" ) ;
92100 t ! ( format!( "{:<4s}" , "a" ) , "a " ) ;
93101 t ! ( format!( "{:^5s}" , "a" ) , " a " ) ;
0 commit comments