File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1013,6 +1013,21 @@ impl PathBuf {
1013
1013
/// * if `path` has a root but no prefix (e.g. `\windows`), it
1014
1014
/// replaces everything except for the prefix (if any) of `self`.
1015
1015
/// * 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
+ /// ```
1016
1031
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1017
1032
pub fn push < P : AsRef < Path > > ( & mut self , path : P ) {
1018
1033
self . _push ( path. as_ref ( ) )
You can’t perform that action at this time.
0 commit comments