Skip to content

Commit 113877f

Browse files
committed
std: mention other methods that normalize a path in normalize_lexically doc
Signed-off-by: xizheyin <[email protected]>
1 parent 99b18d6 commit 113877f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

library/std/src/path.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ impl PathBuf {
12441244
///
12451245
/// The caller has free choice over the returned lifetime, including 'static.
12461246
/// Indeed, this function is ideally used for data that lives for the remainder of
1247-
/// the programs life, as dropping the returned reference will cause a memory leak.
1247+
/// the program's life, as dropping the returned reference will cause a memory leak.
12481248
///
12491249
/// It does not reallocate or shrink the `PathBuf`, so the leaked allocation may include
12501250
/// unused capacity that is not part of the returned slice. If you want to discard excess
@@ -3028,12 +3028,22 @@ impl Path {
30283028
///
30293029
/// This function always resolves `..` to the "lexical" parent.
30303030
/// That is "a/b/../c" will always resolve to `a/c` which can change the meaning of the path.
3031-
/// 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`.
3031+
/// 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`.
30323032
///
30333033
/// </div>
30343034
///
30353035
/// [`path::absolute`](absolute) is an alternative that preserves `..`.
30363036
/// Or [`Path::canonicalize`] can be used to resolve any `..` by querying the filesystem.
3037+
///
3038+
/// # Related normalization functions
3039+
///
3040+
/// Besides this method, several other methods perform basic normalization:
3041+
/// See also: [`Path::components`], [`Path::iter`], [`PartialEq<Path>`], [`PartialOrd<Path>`], [`Ord<Path>`],
3042+
/// [`Path::has_root`], [`PathBuf::push`]
3043+
///
3044+
/// These methods **do not** resolve `..` components or symlinks. For full normalization including `..`,
3045+
/// use this method or [`Path::canonicalize`] (which accesses the filesystem).
3046+
///
30373047
#[unstable(feature = "normalize_lexically", issue = "134694")]
30383048
pub fn normalize_lexically(&self) -> Result<PathBuf, NormalizeError> {
30393049
let mut lexical = PathBuf::new();

0 commit comments

Comments
 (0)