File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,41 @@ impl PathBuf {
8888 pub fn pop ( & mut self ) -> bool {
8989 self . inner . pop ( )
9090 }
91+
92+ /// Extends `self` with `path`.
93+ ///
94+ /// If `path` is absolute, it replaces the current path.
95+ ///
96+ /// On Windows:
97+ ///
98+ /// * if `path` has a root but no prefix (e.g., `\windows`), it
99+ /// replaces everything except for the prefix (if any) of `self`.
100+ /// * if `path` has a prefix but no root, it replaces `self`.
101+ ///
102+ /// # Examples
103+ ///
104+ /// Pushing a relative path extends the existing path:
105+ ///
106+ /// ```
107+ /// use async_std::path::PathBuf;
108+ ///
109+ /// let mut path = PathBuf::from("/tmp");
110+ /// path.push("file.bk");
111+ /// assert_eq!(path, PathBuf::from("/tmp/file.bk"));
112+ /// ```
113+ ///
114+ /// Pushing an absolute path replaces the existing path:
115+ ///
116+ /// ```
117+ /// use async_std::path::PathBuf;
118+ ///
119+ /// let mut path = PathBuf::from("/tmp");
120+ /// path.push("/etc");
121+ /// assert_eq!(path, PathBuf::from("/etc"));
122+ /// ```
123+ pub fn push < P : AsRef < std:: path:: Path > > ( & mut self , path : P ) {
124+ self . inner . push ( path)
125+ }
91126}
92127
93128impl From < std:: path:: PathBuf > for PathBuf {
You can’t perform that action at this time.
0 commit comments