File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1013,6 +1013,21 @@ impl PathBuf {
10131013 /// * if `path` has a root but no prefix (e.g. `\windows`), it
10141014 /// replaces everything except for the prefix (if any) of `self`.
10151015 /// * if `path` has a prefix but no root, it replaces `self`.
1016+ ///
1017+ /// # Examples
1018+ ///
1019+ /// ```
1020+ /// use std::path::PathBuf;
1021+ ///
1022+ /// let mut path = PathBuf::new();
1023+ /// path.push("/tmp");
1024+ /// path.push("file.bk");
1025+ /// assert_eq!(path, PathBuf::from("/tmp/file.bk"));
1026+ ///
1027+ /// // Pushing an absolute path replaces the current path
1028+ /// path.push("/etc/passwd");
1029+ /// assert_eq!(path, PathBuf::from("/etc/passwd"));
1030+ /// ```
10161031 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
10171032 pub fn push < P : AsRef < Path > > ( & mut self , path : P ) {
10181033 self . _push ( path. as_ref ( ) )
You can’t perform that action at this time.
0 commit comments