File tree 1 file changed +11
-10
lines changed
1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -46,22 +46,23 @@ fn get_path_for_executable(executable_name: &'static str) -> PathBuf {
46
46
path. push ( ".cargo" ) ;
47
47
path. push ( "bin" ) ;
48
48
path. push ( executable_name) ;
49
- if path. is_file ( ) {
49
+ if let Some ( path) = probe ( path ) {
50
50
return path;
51
51
}
52
52
}
53
+
53
54
executable_name. into ( )
54
55
}
55
56
56
57
fn lookup_in_path ( exec : & str ) -> bool {
57
58
let paths = env:: var_os ( "PATH" ) . unwrap_or_default ( ) ;
58
- let mut candidates = env:: split_paths ( & paths) . flat_map ( |path| {
59
- let candidate = path . join ( & exec ) ;
60
- let with_exe = match env :: consts :: EXE_EXTENSION {
61
- "" => None ,
62
- it => Some ( candidate . with_extension ( it ) ) ,
63
- } ;
64
- iter :: once ( candidate ) . chain ( with_exe )
65
- } ) ;
66
- candidates . any ( |it| it. is_file ( ) )
59
+ env:: split_paths ( & paths) . map ( |path| path . join ( exec ) ) . find_map ( probe ) . is_some ( )
60
+ }
61
+
62
+ fn probe ( path : PathBuf ) -> Option < PathBuf > {
63
+ let with_extension = match env :: consts :: EXE_EXTENSION {
64
+ "" => None ,
65
+ it => Some ( path . with_extension ( it ) ) ,
66
+ } ;
67
+ iter :: once ( path ) . chain ( with_extension ) . find ( |it| it. is_file ( ) )
67
68
}
You can’t perform that action at this time.
0 commit comments