pub struct AbsPathBuf(/* private fields */);
Expand description
A Utf8PathBuf
that is guaranteed to be absolute.
Implementations§
Source§impl AbsPathBuf
impl AbsPathBuf
Sourcepub fn assert(path: Utf8PathBuf) -> AbsPathBuf
pub fn assert(path: Utf8PathBuf) -> AbsPathBuf
Sourcepub fn assert_utf8(path: PathBuf) -> AbsPathBuf
pub fn assert_utf8(path: PathBuf) -> AbsPathBuf
Sourcepub fn as_path(&self) -> &AbsPath
pub fn as_path(&self) -> &AbsPath
Coerces to an AbsPath
slice.
Equivalent of Utf8PathBuf::as_path
for AbsPathBuf
.
Sourcepub fn pop(&mut self) -> bool
pub fn pop(&mut self) -> bool
Equivalent of Utf8PathBuf::pop
for AbsPathBuf
.
Note that this won’t remove the root component, so self
will still be
absolute.
Sourcepub fn push<P: AsRef<Utf8Path>>(&mut self, suffix: P)
pub fn push<P: AsRef<Utf8Path>>(&mut self, suffix: P)
Equivalent of PathBuf::push
for AbsPathBuf
.
Extends self
with path
.
If path
is absolute, it replaces the current path.
On Windows:
- if
path
has a root but no prefix (e.g.,\windows
), it replaces everything except for the prefix (if any) ofself
. - if
path
has a prefix but no root, it replacesself
. - if
self
has a verbatim prefix (e.g.\\?\C:\windows
) andpath
is not empty, the new path is normalized: all references to.
and..
are removed.
pub fn join(&self, path: impl AsRef<Utf8Path>) -> Self
Methods from Deref<Target = AbsPath>§
Sourcepub fn parent(&self) -> Option<&AbsPath>
pub fn parent(&self) -> Option<&AbsPath>
Equivalent of Utf8Path::parent
for AbsPath
.
Sourcepub 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.
Sourcepub fn join(&self, path: impl AsRef<Utf8Path>) -> AbsPathBuf
pub fn join(&self, path: impl AsRef<Utf8Path>) -> AbsPathBuf
Equivalent of Utf8Path::join
for AbsPath
.
Sourcepub 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()));
Sourcepub 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) -> !
Sourcepub 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 AbsPathBuf
impl AsRef<AbsPath> for AbsPathBuf
Source§impl AsRef<OsStr> for AbsPathBuf
impl AsRef<OsStr> for AbsPathBuf
Source§impl AsRef<Path> for AbsPathBuf
impl AsRef<Path> for AbsPathBuf
Source§impl AsRef<Utf8Path> for AbsPathBuf
impl AsRef<Utf8Path> for AbsPathBuf
Source§impl Borrow<AbsPath> for AbsPathBuf
impl Borrow<AbsPath> for AbsPathBuf
Source§impl Clone for AbsPathBuf
impl Clone for AbsPathBuf
Source§fn clone(&self) -> AbsPathBuf
fn clone(&self) -> AbsPathBuf
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 AbsPathBuf
impl Debug for AbsPathBuf
Source§impl Deref for AbsPathBuf
impl Deref for AbsPathBuf
Source§impl Display for AbsPathBuf
impl Display for AbsPathBuf
Source§impl From<AbsPathBuf> for PathBuf
impl From<AbsPathBuf> for PathBuf
Source§fn from(AbsPathBuf: AbsPathBuf) -> PathBuf
fn from(AbsPathBuf: AbsPathBuf) -> PathBuf
Converts to this type from the input type.
Source§impl From<AbsPathBuf> for Utf8PathBuf
impl From<AbsPathBuf> for Utf8PathBuf
Source§fn from(AbsPathBuf: AbsPathBuf) -> Utf8PathBuf
fn from(AbsPathBuf: AbsPathBuf) -> Utf8PathBuf
Converts to this type from the input type.
Source§impl Hash for AbsPathBuf
impl Hash for AbsPathBuf
Source§impl Ord for AbsPathBuf
impl Ord for AbsPathBuf
Source§fn cmp(&self, other: &AbsPathBuf) -> Ordering
fn cmp(&self, other: &AbsPathBuf) -> 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 PartialOrd for AbsPathBuf
impl PartialOrd for AbsPathBuf
Source§impl TryFrom<&str> for AbsPathBuf
impl TryFrom<&str> for AbsPathBuf
Source§type Error = Utf8PathBuf
type Error = Utf8PathBuf
The type returned in the event of a conversion error.
Source§fn try_from(path: &str) -> Result<AbsPathBuf, Utf8PathBuf>
fn try_from(path: &str) -> Result<AbsPathBuf, Utf8PathBuf>
Performs the conversion.
Source§impl TryFrom<Utf8PathBuf> for AbsPathBuf
impl TryFrom<Utf8PathBuf> for AbsPathBuf
Source§type Error = Utf8PathBuf
type Error = Utf8PathBuf
The type returned in the event of a conversion error.
Source§fn try_from(path_buf: Utf8PathBuf) -> Result<AbsPathBuf, Utf8PathBuf>
fn try_from(path_buf: Utf8PathBuf) -> Result<AbsPathBuf, Utf8PathBuf>
Performs the conversion.
impl Eq for AbsPathBuf
Auto Trait Implementations§
impl Freeze for AbsPathBuf
impl RefUnwindSafe for AbsPathBuf
impl Send for AbsPathBuf
impl Sync for AbsPathBuf
impl Unpin for AbsPathBuf
impl UnwindSafe for AbsPathBuf
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