Skip to content

Commit

Permalink
Remove needless as_fd/as_socket calls (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e authored Oct 8, 2023
1 parent 0b5016e commit d5bc619
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/reactor/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 3 additions & 5 deletions src/reactor/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/reactor/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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(),
}
}

Expand Down

0 comments on commit d5bc619

Please sign in to comment.