File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1055,6 +1055,15 @@ impl DirEntry {
10551055 }
10561056}
10571057
1058+ #[ stable( feature = "dir_entry_debug" , since = "1.13.0" ) ]
1059+ impl fmt:: Debug for DirEntry {
1060+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1061+ f. debug_tuple ( "DirEntry" )
1062+ . field ( & self . path ( ) )
1063+ . finish ( )
1064+ }
1065+ }
1066+
10581067impl AsInner < fs_imp:: DirEntry > for DirEntry {
10591068 fn as_inner ( & self ) -> & fs_imp:: DirEntry { & self . 0 }
10601069}
@@ -2641,6 +2650,17 @@ mod tests {
26412650 }
26422651 }
26432652
2653+ #[ test]
2654+ fn dir_entry_debug ( ) {
2655+ let tmpdir = tmpdir ( ) ;
2656+ File :: create ( & tmpdir. join ( "b" ) ) . unwrap ( ) ;
2657+ let mut read_dir = tmpdir. path ( ) . read_dir ( ) . unwrap ( ) ;
2658+ let dir_entry = read_dir. next ( ) . unwrap ( ) . unwrap ( ) ;
2659+ let actual = format ! ( "{:?}" , dir_entry) ;
2660+ let expected = format ! ( "DirEntry({:?})" , dir_entry. 0 . path( ) ) ;
2661+ assert_eq ! ( actual, expected) ;
2662+ }
2663+
26442664 #[ test]
26452665 fn read_dir_not_found ( ) {
26462666 let res = fs:: read_dir ( "/path/that/does/not/exist" ) ;
You can’t perform that action at this time.
0 commit comments