Navigation Menu

Skip to content

Commit

Permalink
Make RawFd implement the RawFd traits
Browse files Browse the repository at this point in the history
  • Loading branch information
withoutboats committed Sep 20, 2020
1 parent 5e449b9 commit 82f5928
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
19 changes: 19 additions & 0 deletions library/std/src/sys/unix/ext/io.rs
Expand Up @@ -62,6 +62,25 @@ pub trait IntoRawFd {
fn into_raw_fd(self) -> RawFd;
}

#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
impl AsRawFd for RawFd {
fn as_raw_fd(&self) -> RawFd {
*self
}
}
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
impl IntoRawFd for RawFd {
fn as_raw_fd(self) -> RawFd {
self
}
}
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
impl FromRawFd for RawFd {
unsafe fn from_raw_fd(fd: RawFd) -> RawFd {
self
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl AsRawFd for fs::File {
fn as_raw_fd(&self) -> RawFd {
Expand Down
20 changes: 20 additions & 0 deletions library/std/src/sys/vxworks/ext/io.rs
Expand Up @@ -63,6 +63,26 @@ pub trait IntoRawFd {
fn into_raw_fd(self) -> RawFd;
}

#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
impl AsRawFd for RawFd {
fn as_raw_fd(&self) -> RawFd {
*self
}
}
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
impl IntoRawFd for RawFd {
fn as_raw_fd(self) -> RawFd {
self
}
}
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
impl FromRawFd for RawFd {
unsafe fn from_raw_fd(fd: RawFd) -> RawFd {
self
}
}


#[stable(feature = "rust1", since = "1.0.0")]
impl AsRawFd for fs::File {
fn as_raw_fd(&self) -> RawFd {
Expand Down
20 changes: 20 additions & 0 deletions library/std/src/sys/wasi/ext/io.rs
Expand Up @@ -52,6 +52,26 @@ pub trait IntoRawFd {
fn into_raw_fd(self) -> RawFd;
}

#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
impl AsRawFd for RawFd {
fn as_raw_fd(&self) -> RawFd {
*self
}
}
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
impl IntoRawFd for RawFd {
fn as_raw_fd(self) -> RawFd {
self
}
}
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
impl FromRawFd for RawFd {
unsafe fn from_raw_fd(fd: RawFd) -> RawFd {
self
}
}


impl AsRawFd for net::TcpStream {
fn as_raw_fd(&self) -> RawFd {
self.as_inner().fd().as_raw()
Expand Down

0 comments on commit 82f5928

Please sign in to comment.