[−][src]Struct which::CanonicalPath
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.
Methods
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]
binary_name: T,
paths: Option<U>,
cwd: V
) -> Result<CanonicalPath> where
T: AsRef<OsStr>,
U: AsRef<OsStr>,
V: AsRef<Path>,
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 Clone for CanonicalPath
[src]
fn clone(&self) -> CanonicalPath
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl AsRef<Path> for CanonicalPath
[src]
impl AsRef<OsStr> for CanonicalPath
[src]
impl Eq for CanonicalPath
[src]
impl PartialEq<CanonicalPath> for CanonicalPath
[src]
fn eq(&self, other: &CanonicalPath) -> bool
[src]
fn ne(&self, other: &CanonicalPath) -> bool
[src]
impl PartialEq<PathBuf> for CanonicalPath
[src]
impl PartialEq<CanonicalPath> for PathBuf
[src]
fn eq(&self, other: &CanonicalPath) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl Deref for CanonicalPath
[src]
impl Debug for CanonicalPath
[src]
Auto Trait Implementations
impl Send for CanonicalPath
impl Sync for CanonicalPath
impl Unpin for CanonicalPath
impl UnwindSafe for CanonicalPath
impl RefUnwindSafe for CanonicalPath
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,