From f53d062d427f31211ebcb664dc4d7716ef66d8d8 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 13 Nov 2016 12:57:03 -0500 Subject: [PATCH] Minor rewriting of `std::path::Path::push` doc example. --- src/libstd/path.rs | 17 ++++++++++++----- 1 file 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 current path - /// path.push("/etc/passwd"); - /// assert_eq!(path, PathBuf::from("/etc/passwd")); + /// Pushing an absolute path replaces the existing path: + /// + /// ``` + /// use std::path::PathBuf; + /// + /// 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>(&mut self, path: P) {