Rollup merge of #59512 - euclio:stdio-locks, r=sfackler
implement `AsRawFd` for stdio locks cc https://github.com/rust-lang/rfcs/issues/2074.
This commit is contained in:
commit
1b1b8640de
3 changed files with 51 additions and 0 deletions
|
|
@ -115,6 +115,21 @@ impl AsRawFd for io::Stderr {
|
|||
fn as_raw_fd(&self) -> RawFd { 2 }
|
||||
}
|
||||
|
||||
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
|
||||
impl<'a> AsRawFd for io::StdinLock<'a> {
|
||||
fn as_raw_fd(&self) -> RawFd { 0 }
|
||||
}
|
||||
|
||||
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
|
||||
impl<'a> AsRawFd for io::StdoutLock<'a> {
|
||||
fn as_raw_fd(&self) -> RawFd { 1 }
|
||||
}
|
||||
|
||||
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
|
||||
impl<'a> AsRawFd for io::StderrLock<'a> {
|
||||
fn as_raw_fd(&self) -> RawFd { 2 }
|
||||
}
|
||||
|
||||
#[stable(feature = "from_raw_os", since = "1.1.0")]
|
||||
impl FromRawFd for net::TcpStream {
|
||||
unsafe fn from_raw_fd(fd: RawFd) -> net::TcpStream {
|
||||
|
|
|
|||
|
|
@ -95,3 +95,18 @@ impl AsRawFd for io::Stdout {
|
|||
impl AsRawFd for io::Stderr {
|
||||
fn as_raw_fd(&self) -> RawFd { libc::STDERR_FILENO }
|
||||
}
|
||||
|
||||
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
|
||||
impl<'a> AsRawFd for io::StdinLock<'a> {
|
||||
fn as_raw_fd(&self) -> RawFd { libc::STDIN_FILENO }
|
||||
}
|
||||
|
||||
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
|
||||
impl<'a> AsRawFd for io::StdoutLock<'a> {
|
||||
fn as_raw_fd(&self) -> RawFd { libc::STDOUT_FILENO }
|
||||
}
|
||||
|
||||
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
|
||||
impl<'a> AsRawFd for io::StderrLock<'a> {
|
||||
fn as_raw_fd(&self) -> RawFd { libc::STDERR_FILENO }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,27 @@ impl AsRawHandle for io::Stderr {
|
|||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
|
||||
impl<'a> AsRawHandle for io::StdinLock<'a> {
|
||||
fn as_raw_handle(&self) -> RawHandle {
|
||||
unsafe { c::GetStdHandle(c::STD_INPUT_HANDLE) as RawHandle }
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
|
||||
impl<'a> AsRawHandle for io::StdoutLock<'a> {
|
||||
fn as_raw_handle(&self) -> RawHandle {
|
||||
unsafe { c::GetStdHandle(c::STD_OUTPUT_HANDLE) as RawHandle }
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "asraw_stdio_locks", since = "1.35.0")]
|
||||
impl<'a> AsRawHandle for io::StderrLock<'a> {
|
||||
fn as_raw_handle(&self) -> RawHandle {
|
||||
unsafe { c::GetStdHandle(c::STD_ERROR_HANDLE) as RawHandle }
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "from_raw_os", since = "1.1.0")]
|
||||
impl FromRawHandle for fs::File {
|
||||
unsafe fn from_raw_handle(handle: RawHandle) -> fs::File {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue