Function which::source ·
Find an executable binary’s path by name, ignoring
If given an absolute path, returns it if the file exists and is executable.
Does not resolve relative paths.
If given a string without path separators, looks for a file named
binary_name at each directory in
$PATH and if it finds an executable
file there, returns it.
use which::which; use std::path::PathBuf; let result = which::which_global("rustc").unwrap(); assert_eq!(result, PathBuf::from("/usr/bin/rustc"));