File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 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 {
4646 path. push ( ".cargo" ) ;
4747 path. push ( "bin" ) ;
4848 path. push ( executable_name) ;
49- if path. is_file ( ) {
49+ if let Some ( path) = probe ( path ) {
5050 return path;
5151 }
5252 }
53+
5354 executable_name. into ( )
5455}
5556
5657fn lookup_in_path ( exec : & str ) -> bool {
5758 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 ( ) )
6768}
You can’t perform that action at this time.
0 commit comments