Skip to content

Commit eac4b65

Browse files
authored
Merge pull request #1464 from asomers/fdset
Use immutable receivers for FdSet::{highest, contains, fds}
2 parents e493f83 + 50391ef commit eac4b65

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).
66
## [Unreleased] - ReleaseDate
77
### Added
88
### Changed
9+
10+
- `FdSet::{contains, highest, fds}` no longer require a mutable reference.
11+
(#[1464](https://github.com/nix-rust/nix/pull/1464))
12+
913
### Fixed
1014
### Removed
1115

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ targets = [
2525
]
2626

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

src/sys/select.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ impl FdSet {
3232
unsafe { libc::FD_CLR(fd, &mut self.0) };
3333
}
3434

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

3939
pub fn clear(&mut self) {
@@ -57,7 +57,7 @@ impl FdSet {
5757
/// ```
5858
///
5959
/// [`select`]: fn.select.html
60-
pub fn highest(&mut self) -> Option<RawFd> {
60+
pub fn highest(&self) -> Option<RawFd> {
6161
self.fds(None).next_back()
6262
}
6363

@@ -79,7 +79,7 @@ impl FdSet {
7979
/// assert_eq!(fds, vec![4, 9]);
8080
/// ```
8181
#[inline]
82-
pub fn fds(&mut self, highest: Option<RawFd>) -> Fds {
82+
pub fn fds(&self, highest: Option<RawFd>) -> Fds {
8383
Fds {
8484
set: self,
8585
range: 0..highest.map(|h| h as usize + 1).unwrap_or(FD_SETSIZE),
@@ -96,7 +96,7 @@ impl Default for FdSet {
9696
/// Iterator over `FdSet`.
9797
#[derive(Debug)]
9898
pub struct Fds<'a> {
99-
set: &'a mut FdSet,
99+
set: &'a FdSet,
100100
range: Range<usize>,
101101
}
102102

0 commit comments

Comments
 (0)