pub struct Path<'a> { /* private fields */ }Expand description
Path provides a copy-on-write-style path that is built around UTF8 strings.
Implementations§
source§impl<'a> Path<'a>
impl<'a> Path<'a>
sourcepub fn into_owned(self) -> Path<'static>
pub fn into_owned(self) -> Path<'static>
Convert the path into an owned path.
sourcepub fn basename(&self) -> Path<'_>
pub fn basename(&self) -> Path<'_>
Compute the basename of the path. This is guaraneed to be a non-empty path component (falling back to “.” for paths that end with “/”).
sourcepub fn dirname(&self) -> Path<'_>
pub fn dirname(&self) -> Path<'_>
Compute the dirname of the path. This is guaranteed to be a non-empty path component (falling back to “.” or “/” for single-component paths).
sourcepub fn has_root(&self) -> bool
pub fn has_root(&self) -> bool
True if the path begins with some number of slashes, other than the POSIX-exception of //.
sourcepub fn has_app_defined(&self) -> bool
pub fn has_app_defined(&self) -> bool
True if the path begins with //, but not ///.
sourcepub fn is_normal(&self) -> bool
pub fn is_normal(&self) -> bool
True if the path contains no “.” components; and, is absolute and has no “..” components, or is relative and has all “..” components at the start.
sourcepub fn join<'b, 'c>(&self, with: impl Into<Path<'b>>) -> Path<'c>where
'a: 'c,
'b: 'c,
pub fn join<'b, 'c>(&self, with: impl Into<Path<'b>>) -> Path<'c>where
'a: 'c,
'b: 'c,
Join to this path another path. Follows standard path rules where if the joined-with path is absolute, the first path is discarded.
sourcepub fn strip_prefix<'b>(&self, prefix: impl Into<Path<'b>>) -> Option<Path<'_>>
pub fn strip_prefix<'b>(&self, prefix: impl Into<Path<'b>>) -> Option<Path<'_>>
Strip a prefix from the path. The prefix and path are allowed to be non-normal and will have “.” components dropped from consideration.
sourcepub fn split(&self) -> (Path<'_>, Path<'_>)
pub fn split(&self) -> (Path<'_>, Path<'_>)
Split the path into basename and dirname components.
sourcepub fn components(&self) -> impl Iterator<Item = Component<'_>>
pub fn components(&self) -> impl Iterator<Item = Component<'_>>
Return an iterator ovre the path components. A path with a basename of “.” will always end with Component::CurDir.
Trait Implementations§
source§impl<'a> Ord for Path<'a>
impl<'a> Ord for Path<'a>
source§impl<'a> PartialOrd for Path<'a>
impl<'a> PartialOrd for Path<'a>
impl<'a> Eq for Path<'a>
impl<'a> StructuralPartialEq for Path<'a>
Auto Trait Implementations§
impl<'a> Freeze for Path<'a>
impl<'a> RefUnwindSafe for Path<'a>
impl<'a> Send for Path<'a>
impl<'a> Sync for Path<'a>
impl<'a> Unpin for Path<'a>
impl<'a> UnwindSafe for Path<'a>
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)