Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use immutable receivers for FdSet::{highest, contains, fds} #1464

Merged
merged 1 commit into from
Jul 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## [Unreleased] - ReleaseDate
### Added
### Changed

- `FdSet::{contains, highest, fds}` no longer require a mutable reference.
(#[1464](https://github.com/nix-rust/nix/pull/1464))

### Fixed
### Removed

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ targets = [
]

[dependencies]
libc = { version = "0.2.98", features = [ "extra_traits" ] }
libc = { git = "https://github.com/rust-lang/libc", rev = "9c1489fa8", features = [ "extra_traits" ] }
bitflags = "1.1"
cfg-if = "1.0"

Expand Down
10 changes: 5 additions & 5 deletions src/sys/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ impl FdSet {
unsafe { libc::FD_CLR(fd, &mut self.0) };
}

pub fn contains(&mut self, fd: RawFd) -> bool {
unsafe { libc::FD_ISSET(fd, &mut self.0) }
pub fn contains(&self, fd: RawFd) -> bool {
unsafe { libc::FD_ISSET(fd, &self.0) }
}

pub fn clear(&mut self) {
Expand All @@ -57,7 +57,7 @@ impl FdSet {
/// ```
///
/// [`select`]: fn.select.html
pub fn highest(&mut self) -> Option<RawFd> {
pub fn highest(&self) -> Option<RawFd> {
self.fds(None).next_back()
}

Expand All @@ -79,7 +79,7 @@ impl FdSet {
/// assert_eq!(fds, vec![4, 9]);
/// ```
#[inline]
pub fn fds(&mut self, highest: Option<RawFd>) -> Fds {
pub fn fds(&self, highest: Option<RawFd>) -> Fds {
Fds {
set: self,
range: 0..highest.map(|h| h as usize + 1).unwrap_or(FD_SETSIZE),
Expand All @@ -96,7 +96,7 @@ impl Default for FdSet {
/// Iterator over `FdSet`.
#[derive(Debug)]
pub struct Fds<'a> {
set: &'a mut FdSet,
set: &'a FdSet,
range: Range<usize>,
}

Expand Down