#[repr(transparent)]pub struct Path(Path);Expand description
A borrowed native path with lexical operations only.
Filesystem-query methods are deliberately absent. Use this crate’s operation modules to inspect or mutate the host filesystem.
Tuple Fields§
§0: PathImplementations§
Source§impl Path
impl 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 Path
impl AsRef<Path> for Path
Source§fn as_ref(&self) -> &NativePath
fn as_ref(&self) -> &NativePath
Converts this type into a shared reference of the (usually inferred) input type.