Checking if a program exists in $PATH

Hello. I want to check whether a program exists in the $PATH without actually executing it, or printing its output in the console. Currently I'm using

pub fn inxi_exists() -> bool {
    std::process::Command::new("inxi").spawn().is_ok()
}

This prints the output of inxi to stdout which is not desirable.

This stackoverflow answer seems to be what you're looking for.
There is also the which crate.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.