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 @@ -283,3 +283,17 @@ impl<'b, P: AsRef<Path> + 'b> FromStream<P> for PathBuf {
283
283
} )
284
284
}
285
285
}
286
+
287
+ impl < P : AsRef < Path > > std:: iter:: FromIterator < P > for PathBuf {
288
+ fn from_iter < I : IntoIterator < Item = P > > ( iter : I ) -> PathBuf {
289
+ let mut buf = PathBuf :: new ( ) ;
290
+ buf. extend ( iter) ;
291
+ buf
292
+ }
293
+ }
294
+
295
+ impl < P : AsRef < Path > > std:: iter:: Extend < P > for PathBuf {
296
+ fn extend < I : IntoIterator < Item = P > > ( & mut self , iter : I ) {
297
+ iter. into_iter ( ) . for_each ( move |p| self . push ( p. as_ref ( ) ) ) ;
298
+ }
299
+ }
You can’t perform that action at this time.
0 commit comments