diff --git a/src/dir.rs b/src/dir.rs index 62e7b4d5b6..396b54fb03 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -142,6 +142,14 @@ impl Iterator for OwningIter { } } +/// The file descriptor continues to be owned by the `OwningIter`, +/// so callers must not keep a `RawFd` after the `OwningIter` is dropped. +impl AsRawFd for OwningIter { + fn as_raw_fd(&self) -> RawFd { + self.0.as_raw_fd() + } +} + impl IntoIterator for Dir { type Item = Result; type IntoIter = OwningIter;