Commit 9b25f10 Jonathan Turner
authored
File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1055,6 +1055,15 @@ impl DirEntry {
1055
1055
}
1056
1056
}
1057
1057
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
+
1058
1067
impl AsInner < fs_imp:: DirEntry > for DirEntry {
1059
1068
fn as_inner ( & self ) -> & fs_imp:: DirEntry { & self . 0 }
1060
1069
}
@@ -2641,6 +2650,18 @@ mod tests {
2641
2650
}
2642
2651
}
2643
2652
2653
+ #[ test]
2654
+ fn dir_entry_debug ( ) {
2655
+ let tmpdir = tmpdir ( ) ;
2656
+ let file_path = & tmpdir. join ( "b" ) ;
2657
+ File :: create ( file_path) . unwrap ( ) ;
2658
+ let mut read_dir = tmpdir. path ( ) . read_dir ( ) . unwrap ( ) ;
2659
+ let dir_entry = read_dir. next ( ) . unwrap ( ) . unwrap ( ) ;
2660
+ let actual = format ! ( "{:?}" , dir_entry) ;
2661
+ let expected = format ! ( "DirEntry(\" {}\" )" , file_path. display( ) ) ;
2662
+ assert_eq ! ( actual, expected) ;
2663
+ }
2664
+
2644
2665
#[ test]
2645
2666
fn read_dir_not_found ( ) {
2646
2667
let res = fs:: read_dir ( "/path/that/does/not/exist" ) ;
You can’t perform that action at this time.
0 commit comments