Commit 771c047 1 parent d8a177e commit 771c047 Copy full SHA for 771c047
File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ impl Weekday {
171
171
172
172
impl fmt:: Display for Weekday {
173
173
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
174
- f. write_str ( match * self {
174
+ f. pad ( match * self {
175
175
Weekday :: Mon => "Mon" ,
176
176
Weekday :: Tue => "Tue" ,
177
177
Weekday :: Wed => "Wed" ,
@@ -331,6 +331,16 @@ mod tests {
331
331
}
332
332
}
333
333
334
+ #[ test]
335
+ fn test_formatting_alignment ( ) {
336
+ // No exhaustive testing here as we just delegate the
337
+ // implementation to Formatter::pad. Just some basic smoke
338
+ // testing to ensure that it's in fact being done.
339
+ assert_eq ! ( format!( "{:x>7}" , Weekday :: Mon ) , "xxxxMon" ) ;
340
+ assert_eq ! ( format!( "{:^7}" , Weekday :: Mon ) , " Mon " ) ;
341
+ assert_eq ! ( format!( "{:Z<7}" , Weekday :: Mon ) , "MonZZZZ" ) ;
342
+ }
343
+
334
344
#[ test]
335
345
#[ cfg( feature = "serde" ) ]
336
346
fn test_serde_serialize ( ) {
You can’t perform that action at this time.
0 commit comments