@@ -214,7 +214,7 @@ pub struct Permissions(fs_imp::FilePermissions);
214214/// A structure representing a type of file with accessors for each file type.
215215/// It is returned by [`Metadata::file_type`] method.
216216#[ stable( feature = "file_type" , since = "1.1.0" ) ]
217- #[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
217+ #[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
218218#[ cfg_attr( not( test) , rustc_diagnostic_item = "FileType" ) ]
219219pub struct FileType ( fs_imp:: FileType ) ;
220220
@@ -1410,15 +1410,20 @@ impl Metadata {
14101410#[ stable( feature = "std_debug" , since = "1.16.0" ) ]
14111411impl fmt:: Debug for Metadata {
14121412 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 ( )
14221427 }
14231428}
14241429
@@ -1684,6 +1689,17 @@ impl FileType {
16841689 }
16851690}
16861691
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+
16871703impl AsInner < fs_imp:: FileType > for FileType {
16881704 #[ inline]
16891705 fn as_inner ( & self ) -> & fs_imp:: FileType {
0 commit comments