#[repr(transparent)]pub struct PathBuf(PathBuf);Expand description
An owned native path with lexical operations only.
Tuple Fields§
§0: PathBufImplementations§
Source§impl PathBuf
impl PathBuf
Sourcepub fn push<S>(&mut self, path: S)where
S: AsRef<NativePath>,
pub fn push<S>(&mut self, path: S)where
S: AsRef<NativePath>,
Append a lexical path.
Sourcepub fn set_extension<S>(&mut self, extension: S) -> bool
pub fn set_extension<S>(&mut self, extension: S) -> bool
Replace the final extension.
Sourcepub fn into_os_string(self) -> OsString
pub fn into_os_string(self) -> OsString
Consume this path as an operating-system string.
Methods from Deref<Target = Path>§
Sourcepub fn display(&self) -> Display<'_>
pub fn display(&self) -> Display<'_>
Return a display adapter that replaces invalid UTF-8 lossily.
Sourcepub fn to_string_lossy(&self) -> Cow<'_, str>
pub fn to_string_lossy(&self) -> Cow<'_, str>
Return this path as a potentially lossy string.
Sourcepub fn to_path_buf(&self) -> PathBuf
pub fn to_path_buf(&self) -> PathBuf
Allocate an owned copy.
Sourcepub fn join<S>(&self, path: S) -> PathBufwhere
S: AsRef<NativePath>,
pub fn join<S>(&self, path: S) -> PathBufwhere
S: AsRef<NativePath>,
Join a lexical path segment.
Sourcepub fn file_stem(&self) -> Option<&OsStr>
pub fn file_stem(&self) -> Option<&OsStr>
Return the final component without its last extension.
Sourcepub fn with_file_name<S>(&self, file_name: S) -> PathBuf
pub fn with_file_name<S>(&self, file_name: S) -> PathBuf
Return a path with a different final component.
Sourcepub fn with_extension<S>(&self, extension: S) -> PathBuf
pub fn with_extension<S>(&self, extension: S) -> PathBuf
Return a path with a different extension.
Sourcepub fn components(&self) -> Components<'_> ⓘ
pub fn components(&self) -> Components<'_> ⓘ
Iterate over normalized lexical components.
Sourcepub fn starts_with<S>(&self, base: S) -> boolwhere
S: AsRef<NativePath>,
pub fn starts_with<S>(&self, base: S) -> boolwhere
S: AsRef<NativePath>,
Report whether this path begins with base on component boundaries.
Sourcepub fn strip_prefix<S>(&self, base: S) -> Result<&Self, StripPrefixError>where
S: AsRef<NativePath>,
pub fn strip_prefix<S>(&self, base: S) -> Result<&Self, StripPrefixError>where
S: AsRef<NativePath>,
Remove a component-aligned prefix.
§Errors
Returns an error when base is not a lexical prefix of this path.
Sourcepub fn is_absolute(&self) -> bool
pub fn is_absolute(&self) -> bool
Report whether the path is absolute for the current platform.
Trait Implementations§
Source§impl AsRef<Path> for PathBuf
impl AsRef<Path> for PathBuf
Source§fn as_ref(&self) -> &NativePath
fn as_ref(&self) -> &NativePath
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl<'de> Deserialize<'de> for PathBuf
impl<'de> Deserialize<'de> for PathBuf
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<&Path> for PathBuf
impl From<&Path> for PathBuf
Source§fn from(path: &NativePath) -> Self
fn from(path: &NativePath) -> Self
Converts to this type from the input type.
Source§impl From<PathBuf> for PathBuf
impl From<PathBuf> for PathBuf
Source§fn from(path: NativePathBuf) -> Self
fn from(path: NativePathBuf) -> Self
Converts to this type from the input type.
Source§impl Ord for PathBuf
impl Ord for PathBuf
Source§impl PartialOrd for PathBuf
impl PartialOrd for PathBuf
impl Eq for PathBuf
impl StructuralPartialEq 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 UnsafeUnpin 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
Mutably borrows from an owned value. Read more