From d5bc619021b056f0e334950a22a756e1733e3812 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 8 Oct 2023 13:48:08 +0900 Subject: [PATCH] Remove needless as_fd/as_socket calls (#158) --- src/reactor/kqueue.rs | 6 +++--- src/reactor/unix.rs | 8 +++----- src/reactor/windows.rs | 6 +++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/reactor/kqueue.rs b/src/reactor/kqueue.rs index 9f31af9..c1fa0b2 100644 --- a/src/reactor/kqueue.rs +++ b/src/reactor/kqueue.rs @@ -7,7 +7,7 @@ use polling::{Event, PollMode, Poller}; use std::fmt; use std::io::Result; -use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd}; +use std::os::unix::io::{AsRawFd, BorrowedFd, RawFd}; use std::process::Child; /// The raw registration into the reactor. @@ -47,8 +47,8 @@ impl Registration { /// # Safety /// /// The provided file descriptor must be valid and not be closed while this object is alive. - pub(crate) unsafe fn new(f: impl AsFd) -> Self { - Self::Fd(f.as_fd().as_raw_fd()) + pub(crate) unsafe fn new(f: BorrowedFd<'_>) -> Self { + Self::Fd(f.as_raw_fd()) } /// Registers the object into the reactor. diff --git a/src/reactor/unix.rs b/src/reactor/unix.rs index b2f9b1b..6c9f1aa 100644 --- a/src/reactor/unix.rs +++ b/src/reactor/unix.rs @@ -4,7 +4,7 @@ use polling::{Event, Poller}; use std::fmt; use std::io::Result; -use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd, RawFd}; +use std::os::unix::io::{AsRawFd, BorrowedFd, RawFd}; /// The raw registration into the reactor. #[doc(hidden)] @@ -30,10 +30,8 @@ impl Registration { /// # Safety /// /// The provided file descriptor must be valid and not be closed while this object is alive. - pub(crate) unsafe fn new(f: impl AsFd) -> Self { - Self { - raw: f.as_fd().as_raw_fd(), - } + pub(crate) unsafe fn new(f: BorrowedFd<'_>) -> Self { + Self { raw: f.as_raw_fd() } } /// Registers the object into the reactor. diff --git a/src/reactor/windows.rs b/src/reactor/windows.rs index 1c92f00..e81a7eb 100644 --- a/src/reactor/windows.rs +++ b/src/reactor/windows.rs @@ -3,7 +3,7 @@ use polling::{Event, Poller}; use std::fmt; use std::io::Result; -use std::os::windows::io::{AsRawSocket, AsSocket, BorrowedSocket, RawSocket}; +use std::os::windows::io::{AsRawSocket, BorrowedSocket, RawSocket}; /// The raw registration into the reactor. #[doc(hidden)] @@ -29,9 +29,9 @@ impl Registration { /// # Safety /// /// The provided file descriptor must be valid and not be closed while this object is alive. - pub(crate) unsafe fn new(f: impl AsSocket) -> Self { + pub(crate) unsafe fn new(f: BorrowedSocket<'_>) -> Self { Self { - raw: f.as_socket().as_raw_socket(), + raw: f.as_raw_socket(), } }