[][src]Struct which::CanonicalPath

pub struct CanonicalPath { /* fields omitted */ }

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

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

It can be beneficial to use CanonicalPath instead of std::path::Path when you want the type system to enforce the need for a path that exists, points to a binary that is executable, is absolute, has all components normalized, and has all symbolic links resolved

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

Implementations

impl CanonicalPath[src]

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

Returns the canonical path of an executable binary by name.

This calls which and Path::canonicalize and maps the result into a CanonicalPath.

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

Returns the canonical 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 and Path::canonicalize and maps the result into a CanonicalPath.

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::CanonicalPath, yielding its underlying std::path::PathBuf.

Trait Implementations

impl AsRef<OsStr> for CanonicalPath[src]

impl AsRef<Path> for CanonicalPath[src]

impl Clone for CanonicalPath[src]

impl Debug for CanonicalPath[src]

impl Deref for CanonicalPath[src]

type Target = Path

The resulting type after dereferencing.

impl Eq for CanonicalPath[src]

impl PartialEq<CanonicalPath> for CanonicalPath[src]

impl PartialEq<CanonicalPath> for PathBuf[src]

impl PartialEq<PathBuf> for CanonicalPath[src]

impl StructuralPartialEq for CanonicalPath[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.