Skip to content

Commit

Permalink
net: implement IntoRawFd for TcpSocket (#3684)
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Apr 8, 2021
1 parent e89c898 commit 787aca1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tokio/src/net/tcp/socket.rs
Expand Up @@ -5,7 +5,7 @@ use std::io;
use std::net::SocketAddr;

#[cfg(unix)]
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
#[cfg(windows)]
use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};

Expand Down Expand Up @@ -511,6 +511,13 @@ impl FromRawFd for TcpSocket {
}
}

#[cfg(unix)]
impl IntoRawFd for TcpSocket {
fn into_raw_fd(self) -> RawFd {
self.inner.into_raw_fd()
}
}

#[cfg(windows)]
impl IntoRawSocket for TcpSocket {
fn into_raw_socket(self) -> RawSocket {
Expand Down

0 comments on commit 787aca1

Please sign in to comment.