about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-11-13 23:31:54 -0800
committerGitHub <noreply@github.com>2016-11-13 23:31:54 -0800
commit7bef60a64894b0606ad9f5dc76256d5321b270a6 (patch)
tree4db5138f3325c567ed03040b9aa228a54c98fe34 /src
parent435246bb49226d08f22dfd317954fe015a4b3e91 (diff)
parentf53d062d427f31211ebcb664dc4d7716ef66d8d8 (diff)
downloadrust-7bef60a64894b0606ad9f5dc76256d5321b270a6.tar.gz
rust-7bef60a64894b0606ad9f5dc76256d5321b270a6.zip
Auto merge of #37754 - frewsxcv:path-push, r=GuillaumeGomez
Minor rewriting of `std::path::Path::push` doc example.

None
Diffstat (limited to 'src')
-rw-r--r--src/libstd/path.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index bb6883236e8..281e2f17ae6 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -983,17 +983,24 @@ impl PathBuf {
     ///
     /// # Examples
     ///
+    /// Pushing a relative path extends the existing path:
+    ///
     /// ```
     /// use std::path::PathBuf;
     ///
-    /// let mut path = PathBuf::new();
-    /// path.push("/tmp");
+    /// let mut path = PathBuf::from("/tmp");
     /// path.push("file.bk");
     /// assert_eq!(path, PathBuf::from("/tmp/file.bk"));
+    /// ```
+    ///
+    /// Pushing an absolute path replaces the existing path:
+    ///
+    /// ```
+    /// use std::path::PathBuf;
     ///
-    /// // Pushing an absolute path replaces the current path
-    /// path.push("/etc/passwd");
-    /// assert_eq!(path, PathBuf::from("/etc/passwd"));
+    /// let mut path = PathBuf::from("/tmp");
+    /// path.push("/etc");
+    /// assert_eq!(path, PathBuf::from("/etc"));
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn push<P: AsRef<Path>>(&mut self, path: P) {