Skip to content

Commit 82f5928

Browse files
committed
Make RawFd implement the RawFd traits
1 parent 5e449b9 commit 82f5928

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

library/std/src/sys/unix/ext/io.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,25 @@ pub trait IntoRawFd {
6262
fn into_raw_fd(self) -> RawFd;
6363
}
6464

65+
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
66+
impl AsRawFd for RawFd {
67+
fn as_raw_fd(&self) -> RawFd {
68+
*self
69+
}
70+
}
71+
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
72+
impl IntoRawFd for RawFd {
73+
fn as_raw_fd(self) -> RawFd {
74+
self
75+
}
76+
}
77+
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
78+
impl FromRawFd for RawFd {
79+
unsafe fn from_raw_fd(fd: RawFd) -> RawFd {
80+
self
81+
}
82+
}
83+
6584
#[stable(feature = "rust1", since = "1.0.0")]
6685
impl AsRawFd for fs::File {
6786
fn as_raw_fd(&self) -> RawFd {

library/std/src/sys/vxworks/ext/io.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ pub trait IntoRawFd {
6363
fn into_raw_fd(self) -> RawFd;
6464
}
6565

66+
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
67+
impl AsRawFd for RawFd {
68+
fn as_raw_fd(&self) -> RawFd {
69+
*self
70+
}
71+
}
72+
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
73+
impl IntoRawFd for RawFd {
74+
fn as_raw_fd(self) -> RawFd {
75+
self
76+
}
77+
}
78+
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
79+
impl FromRawFd for RawFd {
80+
unsafe fn from_raw_fd(fd: RawFd) -> RawFd {
81+
self
82+
}
83+
}
84+
85+
6686
#[stable(feature = "rust1", since = "1.0.0")]
6787
impl AsRawFd for fs::File {
6888
fn as_raw_fd(&self) -> RawFd {

library/std/src/sys/wasi/ext/io.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ pub trait IntoRawFd {
5252
fn into_raw_fd(self) -> RawFd;
5353
}
5454

55+
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
56+
impl AsRawFd for RawFd {
57+
fn as_raw_fd(&self) -> RawFd {
58+
*self
59+
}
60+
}
61+
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
62+
impl IntoRawFd for RawFd {
63+
fn as_raw_fd(self) -> RawFd {
64+
self
65+
}
66+
}
67+
#[stable(feature = "raw_fd_reflexive_traits", since = "1.48.0")]
68+
impl FromRawFd for RawFd {
69+
unsafe fn from_raw_fd(fd: RawFd) -> RawFd {
70+
self
71+
}
72+
}
73+
74+
5575
impl AsRawFd for net::TcpStream {
5676
fn as_raw_fd(&self) -> RawFd {
5777
self.as_inner().fd().as_raw()

0 commit comments

Comments
 (0)