[][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 AsRef<Path> for Path[src]

impl AsRef<OsStr> for Path[src]

impl Clone for Path[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl PartialEq<Path> for Path[src]

impl PartialEq<PathBuf> for Path[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl PartialEq<Path> for PathBuf[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl Eq for Path[src]

impl Debug for Path[src]

impl Deref for Path[src]

type Target = Path

The resulting type after dereferencing.

Auto Trait Implementations

impl Unpin for Path

impl Sync for Path

impl Send for Path

impl UnwindSafe for Path

impl RefUnwindSafe for Path

Blanket Implementations

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

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, 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]