From 89d6f9e4d4b4c759d7cf5ba4771bbe9b6c14af41 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 ed70a458ac..a84775d349 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -141,6 +141,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;