Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@
//! matter the platform or filesystem. An exception to this is made for Windows
//! drive letters.
//!
//! ## Path normalization
//!
//! Several methods in this module perform basic path normalization by disregarding
//! repeated separators, non-leading `.` components, and trailing separators. These include:
//! - Methods for iteration, such as [`Path::components`] and [`Path::iter`]
//! - Methods for inspection, such as [`Path::has_root`]
//! - Comparisons using [`PartialEq`], [`PartialOrd`], and [`Ord`]
//!
//! [`Path::join`] and [`PathBuf::push`] also disregard trailing slashes.
//!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since they all say they do the same normalization, it would probably be good to move that part outside of the list. Maybe roughly:

Several methods in this module perform basic path normalization by disregarding
repeated separators, non-leading `.` components, and trailing separators. These include:

- Methods for iteration, such as [`Path::components`] and [`Path::iter`]
- Methods for inspection, such as [`Path::has_root`]
- Comparisons using [`PartialEq`]` and [`PartialOrd`]

[`Path::join`] and [`PathBuf::push`] also disregard trailing slashes.

I moved push and join out since I think they don't really interact with anything other than the trailing separator?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ord is missing?

- Comparisons using [`PartialEq`], [`PartialOrd`], and [`Ord`]

I revise the doc. Sorry for late response. :)

// FIXME(normalize_lexically): mention normalize_lexically once stable
//! These methods **do not** resolve `..` components or symlinks. For full normalization
//! including `..` resolution, use [`Path::canonicalize`] (which does access the filesystem).
//!
//! ## Simple usage
//!
//! Path manipulation includes both parsing components from slices and building
Expand Down
Loading