File tree 1 file changed +12
-5
lines changed
1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -983,17 +983,24 @@ impl PathBuf {
983
983
///
984
984
/// # Examples
985
985
///
986
+ /// Pushing a relative path extends the existing path:
987
+ ///
986
988
/// ```
987
989
/// use std::path::PathBuf;
988
990
///
989
- /// let mut path = PathBuf::new();
990
- /// path.push("/tmp");
991
+ /// let mut path = PathBuf::from("/tmp");
991
992
/// path.push("file.bk");
992
993
/// 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;
993
1000
///
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"));
997
1004
/// ```
998
1005
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
999
1006
pub fn push < P : AsRef < Path > > ( & mut self , path : P ) {
You can’t perform that action at this time.
0 commit comments