Skip to content

Commit 24e254c

Browse files
Rollup merge of rust-lang#142957 - xizheyin:142931, r=tgross35
std: introduce path normalize methods at top of `std::path` Closes rust-lang#142931 Mention other methods that call `conponents` and `canonicalize` that fully normalize path. And fix two typo. r? libs
2 parents 0efaa3c + 88c296a commit 24e254c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

library/std/src/path.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@
1919
//! matter the platform or filesystem. An exception to this is made for Windows
2020
//! drive letters.
2121
//!
22+
//! ## Path normalization
23+
//!
24+
//! Several methods in this module perform basic path normalization by disregarding
25+
//! repeated separators, non-leading `.` components, and trailing separators. These include:
26+
//! - Methods for iteration, such as [`Path::components`] and [`Path::iter`]
27+
//! - Methods for inspection, such as [`Path::has_root`]
28+
//! - Comparisons using [`PartialEq`], [`PartialOrd`], and [`Ord`]
29+
//!
30+
//! [`Path::join`] and [`PathBuf::push`] also disregard trailing slashes.
31+
//!
32+
// FIXME(normalize_lexically): mention normalize_lexically once stable
33+
//! These methods **do not** resolve `..` components or symlinks. For full normalization
34+
//! including `..` resolution, use [`Path::canonicalize`] (which does access the filesystem).
35+
//!
2236
//! ## Simple usage
2337
//!
2438
//! Path manipulation includes both parsing components from slices and building

0 commit comments

Comments
 (0)