pub struct PathBuf(/* private fields */);Expand description
Owned path type.
Paths are mostly arbitrary sequences of bytes, with two restrictions:
- The path cannot contain any null bytes.
- Each component of the path must be no longer than 255 bytes.
Implementations§
source§impl PathBuf
impl PathBuf
sourcepub fn new<P>(p: &P) -> Self
pub fn new<P>(p: &P) -> Self
Create a new PathBuf.
This panics if the input is invalid, use Path::try_from if
error handling is desired.
§Panics
Panics if the path contains any null bytes or if a component of the path is longer than 255 bytes.
sourcepub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
Get whether the path is absolute (starts with /).
sourcepub fn display(&self) -> BytesDisplay<'_>
pub fn display(&self) -> BytesDisplay<'_>
Get an object that implements Display to allow conveniently
printing paths that may or may not be valid UTF-8. Non-UTF-8
characters will be replaced with ‘�’.
sourcepub fn push(&mut self, path: impl AsRef<[u8]>)
pub fn push(&mut self, path: impl AsRef<[u8]>)
Append to the path.
This will add a separator if needed. Note that if the argument
is an absolute path, self will be replaced with that path.
§Panics
Panics if the argument is not a valid path.
sourcepub fn join(&self, path: impl AsRef<[u8]>) -> PathBuf
pub fn join(&self, path: impl AsRef<[u8]>) -> PathBuf
Create a new PathBuf joining self with path.
This will add a separator if needed. Note that if the argument
is an absolute path, the returned value will be equal to path.
§Panics
Panics if the argument is not a valid path.
sourcepub fn components(&self) -> Components<'_> ⓘ
pub fn components(&self) -> Components<'_> ⓘ
Get an iterator over each Component in the path.
Trait Implementations§
source§impl Ord for PathBuf
impl Ord for PathBuf
source§impl PartialOrd for PathBuf
impl PartialOrd for PathBuf
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Eq for PathBuf
Auto Trait Implementations§
impl Freeze for PathBuf
impl RefUnwindSafe for PathBuf
impl Send for PathBuf
impl Sync for PathBuf
impl Unpin for PathBuf
impl UnwindSafe for PathBuf
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)