diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-01-22 11:43:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-22 11:43:06 +0100 |
| commit | 17b9f2a7edb171b17f0bec50ed4cae1f81b20cb8 (patch) | |
| tree | e4d5b553890c49f438fe255482fd6021d19ec2b0 | |
| parent | 6e79310c55d8a7d594780689c16b129070d9032b (diff) | |
| parent | d8f8adfe3df3cdc882db8ba7dfb9d7fcc8533b82 (diff) | |
| download | rust-17b9f2a7edb171b17f0bec50ed4cae1f81b20cb8.tar.gz rust-17b9f2a7edb171b17f0bec50ed4cae1f81b20cb8.zip | |
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.
| -rw-r--r-- | library/std/src/path.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/library/std/src/path.rs b/library/std/src/path.rs index c3593264e52..2f53cf83936 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -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] |
