pub fn which<T: AsRef<OsStr>>(binary_name: T) -> Result<path::PathBuf> {
    #[cfg(feature = "failure")]
    let cwd = env::current_dir().context(ErrorKind::CannotGetCurrentDir)?;
    #[cfg(not(feature = "failure"))]
    let cwd = env::current_dir().map_err(|_| ErrorKind::CannotGetCurrentDir)?;

    which_in(binary_name, env::var_os("PATH"), &cwd)
}
/// 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
///
/// ``` norun
/// use which::which;
/// use std::path::PathBuf;
///
/// let result = which::which("rustc").unwrap();
/// assert_eq!(result, PathBuf::from("/usr/bin/rustc"));
///
/// ```
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.
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 .
pub fn which<T: AsRef<OsStr>>(binary_name: T) -> Result<path::PathBuf> {
    #[cfg(feature = "failure")]
    let cwd = env::current_dir().context(ErrorKind::CannotGetCurrentDir)?;
    #[cfg(not(feature = "failure"))]
    let cwd = env::current_dir().map_err(|_| ErrorKind::CannotGetCurrentDir)?;
    which_in(binary_name, env::var_os("PATH"), &cwd)
}
pub fn which < T : AsRef < OsStr > > ( binary_name : T ) -> Result < path :: PathBuf > { # [ cfg ( feature " " ) ] let cwd = env :: current_dir ( ) . context ( ErrorKind :: CannotGetCurrentDir ) ? ; # [ cfg ( not ( feature " " ) ) ] let cwd = env :: current_dir ( ) . map_err ( | _ | ErrorKind :: CannotGetCurrentDir ) ? ; which_in ( binary_name , env :: var_os ( " " ) , & cwd ) }
Find a exectable binary's path by name.
Find a exectable binary ' s path by name .
binary_name
T
binary_name
T
example
``` norun
use which::which;
use std::path::PathBuf.

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


` ` ` norun use which :: which ; use std :: path :: PathBuf . let result = which :: which ( " rustc " ) . unwrap () ; assert_eq! ( result PathBuf :: from ( " / usr / bin / rustc " )) .