File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 52
52
//! path.push("system32");
53
53
//!
54
54
//! path.set_extension("dll");
55
+ //!
56
+ //! // ... but push is best used if you don't know everything up
57
+ //! // front. If you do, this way is better:
58
+ //! let path: PathBuf = ["c:\\", "windows", "system32.dll"].iter().collect();
55
59
//! ```
56
60
//!
57
61
//! [`Component`]: enum.Component.html
Original file line number Diff line number Diff line change @@ -280,3 +280,17 @@ impl<'b, P: AsRef<Path> + 'b> FromStream<P> for PathBuf {
280
280
} )
281
281
}
282
282
}
283
+
284
+ impl < P : AsRef < Path > > std:: iter:: FromIterator < P > for PathBuf {
285
+ fn from_iter < I : IntoIterator < Item = P > > ( iter : I ) -> PathBuf {
286
+ let mut buf = PathBuf :: new ( ) ;
287
+ buf. extend ( iter) ;
288
+ buf
289
+ }
290
+ }
291
+
292
+ impl < P : AsRef < Path > > std:: iter:: Extend < P > for PathBuf {
293
+ fn extend < I : IntoIterator < Item = P > > ( & mut self , iter : I ) {
294
+ iter. into_iter ( ) . for_each ( move |p| self . push ( p. as_ref ( ) ) ) ;
295
+ }
296
+ }
You can’t perform that action at this time.
0 commit comments