@@ -1882,6 +1882,19 @@ impl FromStr for PathBuf {
18821882
18831883#[ stable( feature = "rust1" , since = "1.0.0" ) ]
18841884impl < P : AsRef < Path > > FromIterator < P > for PathBuf {
1885+ /// Creates a new `PathBuf` from the [`Path`] elements of an iterator.
1886+ ///
1887+ /// This uses [`push`](Self::push) to add each element, so can be used to adjoin multiple path
1888+ /// [components](Components).
1889+ ///
1890+ /// # Examples
1891+ /// ```
1892+ /// # use std::path::PathBuf;
1893+ /// let path = PathBuf::from_iter(["/tmp", "foo", "bar"]);
1894+ /// assert_eq!(path, PathBuf::from("/tmp/foo/bar"));
1895+ /// ```
1896+ ///
1897+ /// See documentation for [`push`](Self::push) for more details on how the path is constructed.
18851898 fn from_iter < I : IntoIterator < Item = P > > ( iter : I ) -> PathBuf {
18861899 let mut buf = PathBuf :: new ( ) ;
18871900 buf. extend ( iter) ;
@@ -1891,6 +1904,20 @@ impl<P: AsRef<Path>> FromIterator<P> for PathBuf {
18911904
18921905#[ stable( feature = "rust1" , since = "1.0.0" ) ]
18931906impl < P : AsRef < Path > > Extend < P > for PathBuf {
1907+ /// Extends `self` with [`Path`] elements from `iter`.
1908+ ///
1909+ /// This uses [`push`](Self::push) to add each element, so can be used to adjoin multiple path
1910+ /// [components](Components).
1911+ ///
1912+ /// # Examples
1913+ /// ```
1914+ /// # use std::path::PathBuf;
1915+ /// let mut path = PathBuf::from("/tmp");
1916+ /// path.extend(["foo", "bar", "file.txt"]);
1917+ /// assert_eq!(path, PathBuf::from("/tmp/foo/bar/file.txt"));
1918+ /// ```
1919+ ///
1920+ /// See documentation for [`push`](Self::push) for more details on how the path is constructed.
18941921 fn extend < I : IntoIterator < Item = P > > ( & mut self , iter : I ) {
18951922 iter. into_iter ( ) . for_each ( move |p| self . push ( p. as_ref ( ) ) ) ;
18961923 }
0 commit comments