Skip to content

std: mention other methods that normalize a path in normalize_lexically doc #142957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 12 additions & 2 deletions library/std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ impl PathBuf {
///
/// The caller has free choice over the returned lifetime, including 'static.
/// Indeed, this function is ideally used for data that lives for the remainder of
/// the programs life, as dropping the returned reference will cause a memory leak.
/// the program's life, as dropping the returned reference will cause a memory leak.
///
/// It does not reallocate or shrink the `PathBuf`, so the leaked allocation may include
/// unused capacity that is not part of the returned slice. If you want to discard excess
Expand Down Expand Up @@ -3028,12 +3028,22 @@ impl Path {
///
/// This function always resolves `..` to the "lexical" parent.
/// That is "a/b/../c" will always resolve to `a/c` which can change the meaning of the path.
/// In particular, `a/c` and `a/b/../c` are distinct on many systems because `b` may be a symbolic link, so its parent isnt `a`.
/// In particular, `a/c` and `a/b/../c` are distinct on many systems because `b` may be a symbolic link, so its parent isn't `a`.
///
/// </div>
///
/// [`path::absolute`](absolute) is an alternative that preserves `..`.
/// Or [`Path::canonicalize`] can be used to resolve any `..` by querying the filesystem.
///
/// # Related normalization functions
///
/// Besides this method, several other methods perform basic normalization:
/// See also: [`Path::components`], [`Path::iter`], [`PartialEq<Path>`], [`PartialOrd<Path>`], [`Ord<Path>`],
/// [`Path::has_root`], [`PathBuf::push`]
///
/// These methods **do not** resolve `..` components or symlinks. For full normalization including `..`,
/// use this method or [`Path::canonicalize`] (which accesses the filesystem).
///
#[unstable(feature = "normalize_lexically", issue = "134694")]
pub fn normalize_lexically(&self) -> Result<PathBuf, NormalizeError> {
let mut lexical = PathBuf::new();
Expand Down
Loading