From ec3da87582a318ddb35d451bdba6d50591ea55ce Mon Sep 17 00:00:00 2001 From: Valdemar Erk Date: Fri, 20 Jan 2023 11:16:38 +0100 Subject: [PATCH 1/2] Add note about absolute paths to Path::join --- library/std/src/path.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/std/src/path.rs b/library/std/src/path.rs index c3593264e520b..500a09ad08abc 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 From d8f8adfe3df3cdc882db8ba7dfb9d7fcc8533b82 Mon Sep 17 00:00:00 2001 From: Valdemar Erk Date: Fri, 20 Jan 2023 12:03:43 +0100 Subject: [PATCH 2/2] add example of joining with a absolute path --- library/std/src/path.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 500a09ad08abc..2f53cf8393691 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2541,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]