pub struct AbsPath(/* private fields */);
Expand description
Wrapper around an absolute Path
.
Implementations§
source§impl AbsPath
impl AbsPath
sourcepub fn parent(&self) -> Option<&AbsPath>
pub fn parent(&self) -> Option<&AbsPath>
Equivalent of Path::parent
for AbsPath
.
sourcepub fn absolutize(&self, path: impl AsRef<Path>) -> AbsPathBuf
pub fn absolutize(&self, path: impl AsRef<Path>) -> AbsPathBuf
Equivalent of Path::join
for AbsPath
with an additional normalize step afterwards.
sourcepub fn join(&self, path: impl AsRef<Path>) -> AbsPathBuf
pub fn join(&self, path: impl AsRef<Path>) -> AbsPathBuf
Equivalent of Path::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 Path::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 Path::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<&OsStr>
pub fn extension(&self) -> Option<&OsStr>
pub fn file_stem(&self) -> Option<&OsStr>
pub fn as_os_str(&self) -> &OsStr
pub fn display(&self) -> Display<'_>
👎Deprecated: use Display instead
pub fn exists(&self) -> bool
👎Deprecated: use std::fs::metadata().is_ok() instead
Trait Implementations§
source§impl AsRef<AbsPath> for AbsPathBuf
impl AsRef<AbsPath> for AbsPathBuf
source§impl Borrow<AbsPath> for AbsPathBuf
impl Borrow<AbsPath> for AbsPathBuf
source§impl PartialEq<AbsPath> for AbsPathBuf
impl PartialEq<AbsPath> for AbsPathBuf
source§impl PartialEq for AbsPath
impl PartialEq for AbsPath
source§impl PartialOrd for AbsPath
impl PartialOrd for AbsPath
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl ToOwned for AbsPath
impl ToOwned for AbsPath
§type Owned = AbsPathBuf
type Owned = AbsPathBuf
The resulting type after obtaining ownership.
source§fn to_owned(&self) -> <AbsPath as ToOwned>::Owned
fn to_owned(&self) -> <AbsPath as ToOwned>::Owned
Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
Uses borrowed data to replace owned data, usually by cloning. Read more
impl Eq for AbsPath
impl StructuralEq for AbsPath
impl StructuralPartialEq for AbsPath
Auto Trait Implementations§
impl RefUnwindSafe for AbsPath
impl Send for AbsPath
impl !Sized for AbsPath
impl Sync for AbsPath
impl Unpin for AbsPath
impl UnwindSafe for AbsPath
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more