File tree 1 file changed +8
-11
lines changed
1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -42,25 +42,22 @@ impl SubCommand {
42
42
for entry in dir. read_dir ( ) ? {
43
43
let entry = entry?;
44
44
let file_type = entry. file_type ( ) ?;
45
- if !( file_type. is_file ( ) || file_type. is_symlink ( ) ) {
46
- continue ;
47
- }
48
- let file_name = entry. file_name ( ) ;
49
- let name = match Path :: new ( & file_name)
50
- . to_str ( )
45
+ let path = entry. path ( ) ;
46
+ let name = match path. file_name ( )
47
+ . and_then ( |name| name. to_str ( ) )
51
48
. and_then ( |name| name. strip_prefix ( c2rust_name) )
52
49
. and_then ( |name| name. strip_prefix ( '-' ) )
50
+ . map ( |name| name. to_owned ( ) )
51
+ . map ( Cow :: from)
52
+ . filter ( |_| file_type. is_file ( ) || file_type. is_symlink ( ) )
53
+ . filter ( |_| path. is_executable ( ) )
53
54
{
54
55
Some ( name) => name,
55
56
None => continue ,
56
57
} ;
57
- let path = entry. path ( ) ;
58
- if !path. is_executable ( ) {
59
- continue ;
60
- }
61
58
sub_commands. push ( Self {
62
59
path : Some ( path) ,
63
- name : name . to_owned ( ) . into ( ) ,
60
+ name,
64
61
} ) ;
65
62
}
66
63
Ok ( sub_commands)
You can’t perform that action at this time.
0 commit comments