[][src]Struct which::Path

pub struct Path { /* fields omitted */ }

An owned, immutable wrapper around a PathBuf containing the path of an executable.

The constructed PathBuf is the output of which or which_in, but which::Path has the advantage of being a type distinct from std::path::Path and std::path::PathBuf.

It can be beneficial to use which::Path instead of std::path::Path when you want the type system to enforce the need for a path that exists and points to a binary that is executable.

Since which::Path implements Deref for std::path::Path, all methods on &std::path::Path are also available to &which::Path values.

Methods

impl Path[src]

pub fn new<T: AsRef<OsStr>>(binary_name: T) -> Result<Path>[src]

Returns the path of an executable binary by name.

This calls which and maps the result into a Path.

pub fn new_in<T, U, V>(binary_name: T, paths: Option<U>, cwd: V) -> Result<Path> where
    T: AsRef<OsStr>,
    U: AsRef<OsStr>,
    V: AsRef<Path>, 
[src]

Returns the path of an executable binary by name in the path list paths and using the current working directory cwd to resolve relative paths.

This calls which_in and maps the result into a Path.

pub fn as_path(&self) -> &Path[src]

Returns a reference to a std::path::Path.

pub fn into_path_buf(self) -> PathBuf[src]

Consumes the which::Path, yielding its underlying std::path::PathBuf.

Trait Implementations

impl Eq for Path[src]

impl Clone for Path[src]

impl AsRef<Path> for Path[src]

impl AsRef<OsStr> for Path[src]

impl PartialEq<Path> for Path[src]

impl PartialEq<PathBuf> for Path[src]

impl PartialEq<Path> for PathBuf[src]

impl Deref for Path[src]

type Target = Path

The resulting type after dereferencing.

impl Debug for Path[src]

Auto Trait Implementations

impl Send for Path

impl Unpin for Path

impl Sync for Path

impl UnwindSafe for Path

impl RefUnwindSafe for Path

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]