From cc57db02a3a41480592a07b5f8544d7aa0c2c2d7 Mon Sep 17 00:00:00 2001 From: Wouter Geraedts Date: Sun, 13 Oct 2019 19:33:55 +0200 Subject: [PATCH] Implemented Path::join --- src/path/path.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/path/path.rs b/src/path/path.rs index 038fd24d..2c4a97a6 100644 --- a/src/path/path.rs +++ b/src/path/path.rs @@ -415,6 +415,27 @@ impl Path { self.inner.iter() } + /// Creates an owned [`PathBuf`] with `path` adjoined to `self`. + /// + /// See [`PathBuf::push`] for more details on what it means to adjoin a path. + /// + /// [`PathBuf`]: struct.PathBuf.html + /// [`PathBuf::push`]: struct.PathBuf.html#method.push + /// + /// # Examples + /// + /// ``` + /// use async_std::path::{Path, PathBuf}; + /// + /// assert_eq!(Path::new("/etc").join("passwd"), PathBuf::from("/etc/passwd")); + /// ``` + pub fn join>(&self, path: P) -> PathBuf + where + P: std::convert::AsRef, + { + self.inner.join(path).into() + } + /// Queries the file system to get information about a file, directory, etc. /// /// This function will traverse symbolic links to query information about the