Function which::which[][src]

pub fn which<T: AsRef<OsStr>>(binary_name: T) -> Result<PathBuf>
Expand description

Find a exectable binary’s path by name.

If given an absolute path, returns it if the file exists and is executable.

If given a relative path, returns an absolute path to the file if it exists and is executable.

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.

Example

use which::which;
use std::path::PathBuf;

let result = which::which("rustc").unwrap();
assert_eq!(result, PathBuf::from("/usr/bin/rustc"));