| skipped 12 lines |
13 | 13 | | |
14 | 14 | | // Get PATH env and join it with bin_dir |
15 | 15 | | fn get_path_env(bin_dirs: Vec<PathBuf>) -> String { |
16 | | - | let mut path = env::var("PATH").unwrap_or_default(); |
17 | | - | for dir in bin_dirs { |
18 | | - | path.push_str(":"); |
19 | | - | path.push_str(dir.to_str().unwrap()); |
20 | | - | } |
21 | | - | path |
| 16 | + | let path = PathBuf::from(env::var("PATH").unwrap_or_default()); |
| 17 | + | env::join_paths( |
| 18 | + | bin_dirs |
| 19 | + | .iter() |
| 20 | + | .chain(env::split_paths(&path).collect::<Vec<PathBuf>>().iter()), |
| 21 | + | ) |
| 22 | + | .ok() |
| 23 | + | .unwrap() |
| 24 | + | .into_string() |
| 25 | + | .unwrap() |
22 | 26 | | } |
23 | 27 | | |
24 | 28 | | // A function to find the closest file |
| skipped 163 lines |