/// looks up a binary in `PATH`
///
/// There may be two reasons to do this:
/// - verify that a command exists before trying to run it
/// - always use the same binary even if the contents of the directories listed
///   in `PATH` changes.
looks up a binary in `PATH`
There may be two reasons to do this:
verify that a command exists before trying to run it
always use the same binary even if the contents of the directories listed
in `PATH` changes.
looks up a binary in ` PATH ` There may be two reasons to do this : verify that a command exists before trying to run it always use the same binary even if the contents of the directories listed in ` PATH ` changes .
fn find_bin_file(file: &str) -> Option<PathBuf> {
    std::env::var("PATH").ok().and_then(|path| {
        path.split(':')
            .map(|p| Path::new(p).join(file))
            .find(|p| p.exists())
    })
}
fn find_bin_file ( file : & str ) -> Option < PathBuf > { std :: env :: var ( " " ) . ok ( ) . and_then ( | path | { path . split ( ':' ) . map ( | p | Path :: new ( p ) . join ( file ) ) . find ( | p | p . exists ( ) ) } ) }
looks up a binary in `PATH`
There may be two reasons to do this:
 verify that a command exists before trying to run it
 always use the same binary even if the contents of the directories listed
in `PATH` changes.
looks up a binary in ` PATH ` There may be two reasons to do this : verify that a command exists before trying to run it always use the same binary even if the contents of the directories listed in ` PATH ` changes .
file
&str