Expand description
Cross-platform path manipulation.
This module provides two types, PathBuf and Path (akin to String
and str), for working with paths abstractly. These types are thin wrappers
around OsString and OsStr respectively, meaning that they work directly
on strings according to the local platform’s path syntax.
Paths can be parsed into Components by iterating over the structure
returned by the components method on Path. Components roughly
correspond to the substrings between path separators (/ or \). You can
reconstruct an equivalent path from components with the push method on
PathBuf; note that the paths may differ syntactically by the
normalization described in the documentation for the components method.
§Feature std
When the std feature is enabled, all types are re-exported directly from
std::path and std::ffi, giving full platform support and filesystem
methods. When std is disabled (the default), lightweight no_std
implementations are provided instead.
Modules§
- ffi
- Re-exports of
std::ffi::OsStrandstd::ffi::OsString.
Structs§
- Ancestors
- An iterator over
Pathand its ancestors. - Components
- An iterator over the
Components of aPath. - Display
- Helper struct for safely printing paths with
format!and{}. - Iter
- An iterator over the
Components of aPath, asOsStrslices. - OsStr
- Borrowed reference to an OS string (see
OsString). - OsString
- A type that can represent owned, mutable platform-native strings, but is cheaply inter-convertible with Rust strings.
- Path
- A slice of a path (akin to
str). - PathBuf
- An owned, mutable path (akin to
String). - Prefix
Component - A structure wrapping a Windows path prefix as well as its unparsed string representation.
- Strip
Prefix Error - An error returned from
Path::strip_prefixif the prefix was not found.
Enums§
Constants§
- MAIN_
SEPARATOR - The primary separator of path components for the current platform, represented as a
char; for example, this is'/'on Unix and'\\'on Windows. - MAIN_
SEPARATOR_ STR - The primary separator of path components for the current platform, represented as a
&str; for example, this is"/"on Unix and"\\"on Windows. - NO_
STD_ IMPL truewhen using the customno_stdimplementation,falsewhen re-exporting fromstd::path.
Functions§
- is_
separator - Determines whether the character is one of the permitted path separators for the current platform.