Function libmacchina::extra::which [−][src]
pub fn which<P>(program_name: P) -> bool where
P: AsRef<Path>,
Search all directories in PATH for a program e.g. ps, grep, etc.
This can be used to check if a particular program exists before running a command
that could return an error in case the program is not installed.
- Returns
true
if a given program is in PATH, andfalse
if it isn’t.
Example
use libmacchina::extra::which; if which("grep") { println!("grep is installed."); } else { println!("grep is not installed."); }