Rollup merge of #107114 - Erk-:add-absolute-note-to-path-join, r=m-ou-se

Add note about absolute paths to Path::join

The note already exists on `PathBuf::push`, but I think it is good to have it on `Path::join` as well since it can cause issues if you are not careful with your input.
This commit is contained in:
Matthias Krüger 2023-01-22 11:43:06 +01:00 committed by GitHub
commit 17b9f2a7ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2531,6 +2531,8 @@ impl Path {
/// Creates an owned [`PathBuf`] with `path` adjoined to `self`.
///
/// If `path` is absolute, it replaces the current path.
///
/// See [`PathBuf::push`] for more details on what it means to adjoin a path.
///
/// # Examples
@ -2539,6 +2541,7 @@ impl Path {
/// use std::path::{Path, PathBuf};
///
/// assert_eq!(Path::new("/etc").join("passwd"), PathBuf::from("/etc/passwd"));
/// assert_eq!(Path::new("/etc").join("/bin/sh"), PathBuf::from("/bin/sh"));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[must_use]