Skip to content

Commit d5bc619

Browse files
authored
Remove needless as_fd/as_socket calls (#158)
1 parent 0b5016e commit d5bc619

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/reactor/kqueue.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use polling::{Event, PollMode, Poller};
77

88
use std::fmt;
99
use std::io::Result;
10-
use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd};
10+
use std::os::unix::io::{AsRawFd, BorrowedFd, RawFd};
1111
use std::process::Child;
1212

1313
/// The raw registration into the reactor.
@@ -47,8 +47,8 @@ impl Registration {
4747
/// # Safety
4848
///
4949
/// The provided file descriptor must be valid and not be closed while this object is alive.
50-
pub(crate) unsafe fn new(f: impl AsFd) -> Self {
51-
Self::Fd(f.as_fd().as_raw_fd())
50+
pub(crate) unsafe fn new(f: BorrowedFd<'_>) -> Self {
51+
Self::Fd(f.as_raw_fd())
5252
}
5353

5454
/// Registers the object into the reactor.

src/reactor/unix.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use polling::{Event, Poller};
44

55
use std::fmt;
66
use std::io::Result;
7-
use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd};
7+
use std::os::unix::io::{AsRawFd, BorrowedFd, RawFd};
88

99
/// The raw registration into the reactor.
1010
#[doc(hidden)]
@@ -30,10 +30,8 @@ impl Registration {
3030
/// # Safety
3131
///
3232
/// The provided file descriptor must be valid and not be closed while this object is alive.
33-
pub(crate) unsafe fn new(f: impl AsFd) -> Self {
34-
Self {
35-
raw: f.as_fd().as_raw_fd(),
36-
}
33+
pub(crate) unsafe fn new(f: BorrowedFd<'_>) -> Self {
34+
Self { raw: f.as_raw_fd() }
3735
}
3836

3937
/// Registers the object into the reactor.

src/reactor/windows.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use polling::{Event, Poller};
44
use std::fmt;
55
use std::io::Result;
6-
use std::os::windows::io::{AsRawSocket, AsSocket, BorrowedSocket, RawSocket};
6+
use std::os::windows::io::{AsRawSocket, BorrowedSocket, RawSocket};
77

88
/// The raw registration into the reactor.
99
#[doc(hidden)]
@@ -29,9 +29,9 @@ impl Registration {
2929
/// # Safety
3030
///
3131
/// The provided file descriptor must be valid and not be closed while this object is alive.
32-
pub(crate) unsafe fn new(f: impl AsSocket) -> Self {
32+
pub(crate) unsafe fn new(f: BorrowedSocket<'_>) -> Self {
3333
Self {
34-
raw: f.as_socket().as_raw_socket(),
34+
raw: f.as_raw_socket(),
3535
}
3636
}
3737

0 commit comments

Comments
 (0)