Skip to content

Commit

Permalink
Merge #1563
Browse files Browse the repository at this point in the history
1563: Impl `AsRawFd` for `OwningIter` r=rtzoeller a=deantvv

For issue #1558

Co-authored-by: Dean Li <deantvv@gmail.com>
  • Loading branch information
bors[bot] and deantvv authored Feb 7, 2022
2 parents 16ceae3 + 08e40c0 commit 0244b83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
(#[1640](https://github.com/nix-rust/nix/pull/1640))
- Added `accept4` on DragonFly, Emscripten, Fuchsia, Illumos, and NetBSD.
(#[1654](https://github.com/nix-rust/nix/pull/1654))
- Added `AsRawFd` implementation on `OwningIter`.
(#[1563](https://github.com/nix-rust/nix/pull/1563))

### Changed

Expand Down
8 changes: 8 additions & 0 deletions src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Entry>;
type IntoIter = OwningIter;
Expand Down

0 comments on commit 0244b83

Please sign in to comment.