pub struct RelPathBuf(/* private fields */);Expand description
An owned representation of a file system path that is guaranteed to be relative and normalized.
This type is to RelPath as std::path::PathBuf is to std::path::Path
Implementations§
Source§impl RelPathBuf
impl RelPathBuf
Methods from Deref<Target = RelPath>§
pub fn is_empty(&self) -> bool
pub fn components(&self) -> RelPathComponents<'_> ⓘ
pub fn ancestors(&self) -> RelPathAncestors<'_> ⓘ
pub fn file_name(&self) -> Option<&str>
pub fn file_stem(&self) -> Option<&str>
pub fn extension(&self) -> Option<&str>
pub fn parent(&self) -> Option<&RelPath>
pub fn starts_with(&self, other: &RelPath) -> bool
Sourcepub fn is_descendant_of(&self, ancestor: &RelPath) -> bool
pub fn is_descendant_of(&self, ancestor: &RelPath) -> bool
Returns true if this path is a strict descendant of ancestor.
Unlike starts_with, this returns false when self == ancestor
and false when ancestor is empty (since every path trivially
starts with the empty prefix).
pub fn ends_with(&self, other: &RelPath) -> bool
pub fn strip_prefix<'a>( &'a self, other: &RelPath, ) -> Result<&'a RelPath, StripPrefixError>
pub fn len(&self) -> usize
pub fn last_n_components(&self, count: usize) -> Option<&RelPath>
pub fn join(&self, other: &RelPath) -> RelPathBuf
pub fn to_rel_path_buf(&self) -> RelPathBuf
pub fn into_arc(&self) -> Arc<RelPath> ⓘ
Sourcepub fn display(&self, style: PathStyle) -> Cow<'_, str>
pub fn display(&self, style: PathStyle) -> Cow<'_, str>
Convert the path into a string with the given path style.
Whenever a path is presented to the user, it should be converted to a string via this method.
Sourcepub fn as_unix_str(&self) -> &str
pub fn as_unix_str(&self) -> &str
Get the internal unix-style representation of the path.
This should not be shown to the user.
Sourcepub fn as_std_path(&self) -> &Path
pub fn as_std_path(&self) -> &Path
Interprets the path as a std::path::Path, suitable for file system calls.
This is guaranteed to be a valid path regardless of the host platform, because
the / is accepted as a path separator on windows.
This should not be shown to the user.
Sourcepub fn absolutize(&self, base: impl AsRef<AbsPath>) -> AbsPathBuf
pub fn absolutize(&self, base: impl AsRef<AbsPath>) -> AbsPathBuf
Resolves this relative path against an absolute base path.
Trait Implementations§
Source§impl AsRef<Path> for RelPathBuf
impl AsRef<Path> for RelPathBuf
Source§impl AsRef<RelPath> for RelPathBuf
impl AsRef<RelPath> for RelPathBuf
Source§impl Borrow<RelPath> for RelPathBuf
impl Borrow<RelPath> for RelPathBuf
Source§impl Clone for RelPathBuf
impl Clone for RelPathBuf
Source§fn clone(&self) -> RelPathBuf
fn clone(&self) -> RelPathBuf
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RelPathBuf
impl Debug for RelPathBuf
Source§impl Deref for RelPathBuf
impl Deref for RelPathBuf
Source§impl<'de> Deserialize<'de> for RelPathBuf
Available on crate feature serde only.
impl<'de> Deserialize<'de> for RelPathBuf
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<RelPathBuf, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<RelPathBuf, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for RelPathBuf
impl Display for RelPathBuf
impl Eq for RelPathBuf
Source§impl Hash for RelPathBuf
impl Hash for RelPathBuf
Source§impl Ord for RelPathBuf
impl Ord for RelPathBuf
Source§fn cmp(&self, other: &RelPathBuf) -> Ordering
fn cmp(&self, other: &RelPathBuf) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for RelPathBuf
impl PartialEq for RelPathBuf
Source§impl PartialEq<RelPath> for RelPathBuf
impl PartialEq<RelPath> for RelPathBuf
Source§impl PartialEq<RelPathBuf> for RelPath
impl PartialEq<RelPathBuf> for RelPath
Source§impl PartialOrd for RelPathBuf
impl PartialOrd for RelPathBuf
Source§impl Serialize for RelPathBuf
impl Serialize for RelPathBuf
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for RelPathBuf
Auto Trait Implementations§
impl Freeze for RelPathBuf
impl RefUnwindSafe for RelPathBuf
impl Send for RelPathBuf
impl Sync for RelPathBuf
impl Unpin for RelPathBuf
impl UnsafeUnpin for RelPathBuf
impl UnwindSafe for RelPathBuf
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> ⓘ
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> ⓘ
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 moreSource§impl<T> PathExt for T
impl<T> PathExt for T
Source§fn compact(&self) -> PathBuf
fn compact(&self) -> PathBuf
~). Read moreSource§fn local_to_wsl(&self) -> Option<PathBuf>
fn local_to_wsl(&self) -> Option<PathBuf>
None if the path cannot be converted into a WSL one (network share).