Skip to content

Commit

Permalink
Relax lifetime requirements for FdSet::{insert, remove, contains}
Browse files Browse the repository at this point in the history
Fixes #2130
  • Loading branch information
asomers committed Sep 23, 2023
1 parent 154a8a4 commit 352446a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased] - ReleaseDate

### Fixed

- Relaxed lifetime requirements for `FdSet::{insert, remove, contains}`.
([#2135](https://github.com/nix-rust/nix/pull/2135))

## [0.27.1] - 2023-08-28

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions src/sys/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ impl<'fd> FdSet<'fd> {
}

/// Add a file descriptor to an `FdSet`
pub fn insert<Fd: AsFd>(&mut self, fd: &'fd Fd) {
pub fn insert<Fd: AsFd + 'fd>(&mut self, fd: Fd) {
assert_fd_valid(fd.as_fd().as_raw_fd());
unsafe { libc::FD_SET(fd.as_fd().as_raw_fd(), &mut self.set) };
}

/// Remove a file descriptor from an `FdSet`
pub fn remove<Fd: AsFd>(&mut self, fd: &'fd Fd) {
pub fn remove<Fd: AsFd + 'fd>(&mut self, fd: Fd) {
assert_fd_valid(fd.as_fd().as_raw_fd());
unsafe { libc::FD_CLR(fd.as_fd().as_raw_fd(), &mut self.set) };
}

/// Test an `FdSet` for the presence of a certain file descriptor.
pub fn contains<Fd: AsFd>(&self, fd: &'fd Fd) -> bool {
pub fn contains<Fd: AsFd + 'fd>(&self, fd: Fd) -> bool {
assert_fd_valid(fd.as_fd().as_raw_fd());
unsafe { libc::FD_ISSET(fd.as_fd().as_raw_fd(), &self.set) }
}
Expand Down

0 comments on commit 352446a

Please sign in to comment.