Skip to content

Commit

Permalink
Implement AsRawHandle for Std* on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Aug 3, 2017
1 parent e9c55d1 commit eac01f1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/libstd/sys/windows/ext/io.rs
Expand Up @@ -15,6 +15,7 @@ use os::windows::raw;
use net;
use sys_common::{self, AsInner, FromInner, IntoInner};
use sys;
use io;
use sys::c;

/// Raw HANDLEs.
Expand Down Expand Up @@ -71,6 +72,27 @@ impl AsRawHandle for fs::File {
}
}

#[stable(feature = "asraw_stdio", since = "1.21.0")]
impl AsRawHandle for io::Stdin {
fn as_raw_handle(&self) -> RawHandle {
unsafe { c::GetStdHandle(c::STD_INPUT_HANDLE) } as RawHandle
}
}

#[stable(feature = "asraw_stdio", since = "1.21.0")]
impl AsRawHandle for io::Stdout {
fn as_raw_handle(&self) -> RawHandle {
unsafe { c::GetStdHandle(c::STD_OUTPUT_HANDLE) } as RawHandle
}
}

#[stable(feature = "asraw_stdio", since = "1.21.0")]
impl AsRawHandle for io::Stderr {
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 {
Expand Down

0 comments on commit eac01f1

Please sign in to comment.