Struct ra_ap_paths::AbsPathBuf
source · [−]pub struct AbsPathBuf(_);
Expand description
Wrapper around an absolute PathBuf
.
Implementations
sourceimpl AbsPathBuf
impl AbsPathBuf
sourcepub fn assert(path: PathBuf) -> AbsPathBuf
pub fn assert(path: PathBuf) -> AbsPathBuf
sourcepub fn as_path(&self) -> &AbsPath
pub fn as_path(&self) -> &AbsPath
Coerces to an AbsPath
slice.
Equivalent of PathBuf::as_path
for AbsPathBuf
.
sourcepub fn pop(&mut self) -> bool
pub fn pop(&mut self) -> bool
Equivalent of PathBuf::pop
for AbsPathBuf
.
Note that this won’t remove the root component, so self
will still be
absolute.
Methods from Deref<Target = AbsPath>
sourcepub fn parent(&self) -> Option<&AbsPath>
pub fn parent(&self) -> Option<&AbsPath>
Equivalent of Path::parent
for AbsPath
.
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
.
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 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<'_>
pub fn exists(&self) -> bool
use std::fs::metadata().is_ok() instead
Trait Implementations
sourceimpl Borrow<AbsPath> for AbsPathBuf
impl Borrow<AbsPath> for AbsPathBuf
sourceimpl Clone for AbsPathBuf
impl Clone for AbsPathBuf
sourcefn clone(&self) -> AbsPathBuf
fn clone(&self) -> AbsPathBuf
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for AbsPathBuf
impl Debug for AbsPathBuf
sourceimpl Deref for AbsPathBuf
impl Deref for AbsPathBuf
sourceimpl From<AbsPathBuf> for PathBuf
impl From<AbsPathBuf> for PathBuf
sourcefn from(AbsPathBuf: AbsPathBuf) -> PathBuf
fn from(AbsPathBuf: AbsPathBuf) -> PathBuf
Performs the conversion.
sourceimpl Hash for AbsPathBuf
impl Hash for AbsPathBuf
sourceimpl Ord for AbsPathBuf
impl Ord for AbsPathBuf
sourceimpl PartialEq<AbsPath> for AbsPathBuf
impl PartialEq<AbsPath> for AbsPathBuf
sourceimpl PartialEq<AbsPathBuf> for AbsPathBuf
impl PartialEq<AbsPathBuf> for AbsPathBuf
sourcefn eq(&self, other: &AbsPathBuf) -> bool
fn eq(&self, other: &AbsPathBuf) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &AbsPathBuf) -> bool
fn ne(&self, other: &AbsPathBuf) -> bool
This method tests for !=
.
sourceimpl PartialOrd<AbsPathBuf> for AbsPathBuf
impl PartialOrd<AbsPathBuf> for AbsPathBuf
sourcefn partial_cmp(&self, other: &AbsPathBuf) -> Option<Ordering>
fn partial_cmp(&self, other: &AbsPathBuf) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
sourceimpl TryFrom<&'_ str> for AbsPathBuf
impl TryFrom<&'_ str> for AbsPathBuf
sourceimpl TryFrom<PathBuf> for AbsPathBuf
impl TryFrom<PathBuf> for AbsPathBuf
impl Eq for AbsPathBuf
impl StructuralEq for AbsPathBuf
impl StructuralPartialEq for AbsPathBuf
Auto Trait Implementations
impl RefUnwindSafe for AbsPathBuf
impl Send for AbsPathBuf
impl Sync for AbsPathBuf
impl Unpin for AbsPathBuf
impl UnwindSafe for AbsPathBuf
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more