File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -983,17 +983,24 @@ impl PathBuf {
983983 ///
984984 /// # Examples
985985 ///
986+ /// Pushing a relative path extends the existing path:
987+ ///
986988 /// ```
987989 /// use std::path::PathBuf;
988990 ///
989- /// let mut path = PathBuf::new();
990- /// path.push("/tmp");
991+ /// let mut path = PathBuf::from("/tmp");
991992 /// path.push("file.bk");
992993 /// assert_eq!(path, PathBuf::from("/tmp/file.bk"));
994+ /// ```
995+ ///
996+ /// Pushing an absolute path replaces the existing path:
997+ ///
998+ /// ```
999+ /// use std::path::PathBuf;
9931000 ///
994- /// // Pushing an absolute path replaces the current path
995- /// path.push("/etc/passwd ");
996- /// assert_eq!(path, PathBuf::from("/etc/passwd "));
1001+ /// let mut path = PathBuf::from("/tmp");
1002+ /// path.push("/etc");
1003+ /// assert_eq!(path, PathBuf::from("/etc"));
9971004 /// ```
9981005 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
9991006 pub fn push < P : AsRef < Path > > ( & mut self , path : P ) {
You can’t perform that action at this time.
0 commit comments