@@ -214,7 +214,7 @@ pub struct Permissions(fs_imp::FilePermissions);
214
214
/// A structure representing a type of file with accessors for each file type.
215
215
/// It is returned by [`Metadata::file_type`] method.
216
216
#[ stable( feature = "file_type" , since = "1.1.0" ) ]
217
- #[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
217
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
218
218
#[ cfg_attr( not( test) , rustc_diagnostic_item = "FileType" ) ]
219
219
pub struct FileType ( fs_imp:: FileType ) ;
220
220
@@ -1410,15 +1410,20 @@ impl Metadata {
1410
1410
#[ stable( feature = "std_debug" , since = "1.16.0" ) ]
1411
1411
impl fmt:: Debug for Metadata {
1412
1412
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1413
- f. debug_struct ( "Metadata" )
1414
- . field ( "file_type" , & self . file_type ( ) )
1415
- . field ( "is_dir" , & self . is_dir ( ) )
1416
- . field ( "is_file" , & self . is_file ( ) )
1417
- . field ( "permissions" , & self . permissions ( ) )
1418
- . field ( "modified" , & self . modified ( ) )
1419
- . field ( "accessed" , & self . accessed ( ) )
1420
- . field ( "created" , & self . created ( ) )
1421
- . finish_non_exhaustive ( )
1413
+ let mut debug = f. debug_struct ( "Metadata" ) ;
1414
+ debug. field ( "file_type" , & self . file_type ( ) ) ;
1415
+ debug. field ( "permissions" , & self . permissions ( ) ) ;
1416
+ debug. field ( "len" , & self . len ( ) ) ;
1417
+ if let Ok ( modified) = self . modified ( ) {
1418
+ debug. field ( "modified" , & modified) ;
1419
+ }
1420
+ if let Ok ( accessed) = self . accessed ( ) {
1421
+ debug. field ( "accessed" , & accessed) ;
1422
+ }
1423
+ if let Ok ( created) = self . created ( ) {
1424
+ debug. field ( "created" , & created) ;
1425
+ }
1426
+ debug. finish_non_exhaustive ( )
1422
1427
}
1423
1428
}
1424
1429
@@ -1684,6 +1689,17 @@ impl FileType {
1684
1689
}
1685
1690
}
1686
1691
1692
+ #[ stable( feature = "std_debug" , since = "1.16.0" ) ]
1693
+ impl fmt:: Debug for FileType {
1694
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1695
+ f. debug_struct ( "FileType" )
1696
+ . field ( "is_file" , & self . is_file ( ) )
1697
+ . field ( "is_dir" , & self . is_dir ( ) )
1698
+ . field ( "is_symlink" , & self . is_symlink ( ) )
1699
+ . finish_non_exhaustive ( )
1700
+ }
1701
+ }
1702
+
1687
1703
impl AsInner < fs_imp:: FileType > for FileType {
1688
1704
#[ inline]
1689
1705
fn as_inner ( & self ) -> & fs_imp:: FileType {
0 commit comments