From 378530d6159a6732053ae02585df7ac5a8961c37 Mon Sep 17 00:00:00 2001 From: Dean Li Date: Sat, 16 Oct 2021 12:33:50 +0800 Subject: [PATCH] Impl `AsRawFd` for `OwningIter` For issue #1558 --- src/dir.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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;