Skip to content

Commit 6ad6cc3

Browse files
committed
Implement IntoIterator for &{Path, PathBuf}
Closes #26220.
1 parent af6e413 commit 6ad6cc3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/libstd/path.rs

+14
Original file line numberDiff line numberDiff line change
@@ -1856,6 +1856,20 @@ impl AsRef<Path> for PathBuf {
18561856
fn as_ref(&self) -> &Path { self }
18571857
}
18581858

1859+
#[stable(feature = "path_into_iter", since = "1.6.0")]
1860+
impl<'a> IntoIterator for &'a PathBuf {
1861+
type Item = &'a OsStr;
1862+
type IntoIter = Iter<'a>;
1863+
fn into_iter(self) -> Iter<'a> { self.iter() }
1864+
}
1865+
1866+
#[stable(feature = "path_into_iter", since = "1.6.0")]
1867+
impl<'a> IntoIterator for &'a Path {
1868+
type Item = &'a OsStr;
1869+
type IntoIter = Iter<'a>;
1870+
fn into_iter(self) -> Iter<'a> { self.iter() }
1871+
}
1872+
18591873
#[cfg(test)]
18601874
mod tests {
18611875
use super::*;

0 commit comments

Comments
 (0)