Auto merge of #76969 - withoutboats:rawfd-refexive-traits, r=dtolnay
Make RawFd implement the RawFd traits This PR makes `RawFd` implement `AsRawFd`, `IntoRawFd` and `FromRawFd`, so it can be passed to interfaces that use one of those traits as a bound.
This commit is contained in:
commit
2ad6187ce5
@ -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 into_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 {
|
||||
fd
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl AsRawFd for fs::File {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
|
@ -63,6 +63,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 into_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 {
|
||||
fd
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl AsRawFd for fs::File {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
|
@ -52,6 +52,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 into_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 {
|
||||
fd
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRawFd for net::TcpStream {
|
||||
fn as_raw_fd(&self) -> RawFd {
|
||||
self.as_inner().fd().as_raw()
|
||||
|
Loading…
Reference in New Issue
Block a user