pub struct ManifestPath { /* private fields */ }
Expand description
More or less [AbsPathBuf
] with non-None parent.
We use it to store path to Cargo.toml, as we frequently use the parent dir
as a working directory to spawn various commands, and its nice to not have
to .unwrap()
everywhere.
This could have been named AbsNonRootPathBuf
, as we don’t enforce that
this stores manifest files in particular, but we only use this for manifests
at the moment in practice.
Implementations§
Source§impl ManifestPath
impl ManifestPath
pub fn parent(&self) -> &AbsPath
pub fn canonicalize(&self) -> !
pub fn is_rust_manifest(&self) -> bool
Methods from Deref<Target = AbsPath>§
pub fn absolutize(&self, path: impl AsRef<Utf8Path>) -> AbsPathBuf
pub fn absolutize(&self, path: impl AsRef<Utf8Path>) -> AbsPathBuf
Equivalent of [Utf8Path::join
] for AbsPath
with an additional normalize step afterwards.
pub fn join(&self, path: impl AsRef<Utf8Path>) -> AbsPathBuf
pub fn join(&self, path: impl AsRef<Utf8Path>) -> AbsPathBuf
Equivalent of [Utf8Path::join
] for AbsPath
.
pub fn normalize(&self) -> AbsPathBuf
pub fn normalize(&self) -> AbsPathBuf
Normalize the given path:
- Removes repeated separators:
/a//b
becomes/a/b
- Removes occurrences of
.
and resolves..
. - Removes trailing slashes:
/a/b/
becomes/a/b
.
§Example
let abs_path_buf = AbsPathBuf::assert("/a/../../b/.//c//".into());
let normalized = abs_path_buf.normalize();
assert_eq!(normalized, AbsPathBuf::assert("/b/c".into()));
pub fn to_path_buf(&self) -> AbsPathBuf
pub fn to_path_buf(&self) -> AbsPathBuf
Equivalent of [Utf8Path::to_path_buf
] for AbsPath
.
pub fn canonicalize(&self) -> !
pub fn strip_prefix(&self, base: &AbsPath) -> Option<&RelPath>
pub fn strip_prefix(&self, base: &AbsPath) -> Option<&RelPath>
Equivalent of [Utf8Path::strip_prefix
] for AbsPath
.
Returns a relative path.
pub fn starts_with(&self, base: &AbsPath) -> bool
pub fn ends_with(&self, suffix: &RelPath) -> bool
pub fn name_and_extension(&self) -> Option<(&str, Option<&str>)>
pub fn file_name(&self) -> Option<&str>
pub fn extension(&self) -> Option<&str>
pub fn file_stem(&self) -> Option<&str>
pub fn as_os_str(&self) -> &OsStr
pub fn as_str(&self) -> &str
pub fn display(&self) -> !
👎Deprecated: use Display instead
pub fn exists(&self) -> !
👎Deprecated: use std::fs::metadata().is_ok() instead
pub fn components(&self) -> Utf8Components<'_>
Trait Implementations§
Source§impl AsRef<AbsPath> for ManifestPath
impl AsRef<AbsPath> for ManifestPath
Source§impl AsRef<OsStr> for ManifestPath
impl AsRef<OsStr> for ManifestPath
Source§impl AsRef<Path> for ManifestPath
impl AsRef<Path> for ManifestPath
Source§impl Borrow<AbsPath> for ManifestPath
impl Borrow<AbsPath> for ManifestPath
Source§impl Clone for ManifestPath
impl Clone for ManifestPath
Source§fn clone(&self) -> ManifestPath
fn clone(&self) -> ManifestPath
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ManifestPath
impl Debug for ManifestPath
Source§impl Deref for ManifestPath
impl Deref for ManifestPath
Source§impl Display for ManifestPath
impl Display for ManifestPath
Source§impl From<ManifestPath> for AbsPathBuf
impl From<ManifestPath> for AbsPathBuf
Source§fn from(it: ManifestPath) -> Self
fn from(it: ManifestPath) -> Self
Converts to this type from the input type.
Source§impl Hash for ManifestPath
impl Hash for ManifestPath
Source§impl Ord for ManifestPath
impl Ord for ManifestPath
Source§fn cmp(&self, other: &ManifestPath) -> Ordering
fn cmp(&self, other: &ManifestPath) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ManifestPath
impl PartialEq for ManifestPath
Source§impl PartialOrd for ManifestPath
impl PartialOrd for ManifestPath
Source§impl TryFrom<AbsPathBuf> for ManifestPath
impl TryFrom<AbsPathBuf> for ManifestPath
impl Eq for ManifestPath
impl StructuralPartialEq for ManifestPath
Auto Trait Implementations§
impl Freeze for ManifestPath
impl RefUnwindSafe for ManifestPath
impl Send for ManifestPath
impl Sync for ManifestPath
impl Unpin for ManifestPath
impl UnwindSafe for ManifestPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more