-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement RFC 1014 #26168
Implement RFC 1014 #26168
Conversation
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
cc @retep998 |
enum MaybeRead<R> { | ||
Real(R), | ||
Empty, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this could just be:
enum Maybe<T> {
Real(T),
Empty,
}
impl<W: Write> Write for Maybe<W> { ... }
impl<R: Read> Read for Maybe<W> { ... }
Thanks @sfackler! A few notes:
|
Updated |
pub fn new() -> Stdout { | ||
Stdout(get(c::STD_OUTPUT_HANDLE).unwrap()) | ||
pub fn new() -> io::Result<Stdout> { | ||
Stdout(try!(get(c::STD_OUTPUT_HANDLE))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs a surrounding Ok
(above as well), perhaps jut a get(...).map(|handle| ...)
?
Just a few minor nits, but otherwise r=me, thanks @sfackler! |
@bors r=alexcrichton 517d3bd |
⌛ Testing commit 517d3bd with merge bdde81d... |
💔 Test failed - auto-win-gnu-64-opt |
#[cfg(windows)] | ||
fn close_stdout() { | ||
pub const STD_OUTPUT_HANDLE: libc::DWORD = -11i32 as libc::DWORD; | ||
unsafe { libc::CloseHandle(STD_OUTPUT_HANDLE); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
STD_OUTPUT_HANDLE
isn't aHANDLE
so you need toGetStdHandle
to get the actualHANDLE
toCloseHandle
.- Write a separate test which does
SetStdHandle(STD_OUTPUT_HANDLE, NULL)
so it can testprintln!
's ability to replace stdout with a sink, rather than just stdout's ability to ignore errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
155dd8f
to
7e4ae36
Compare
Closes rust-lang#25977 The various `stdfoo_raw` methods in std::io now return `io::Result`s, since they may not exist on Windows. They will always return `Ok` on Unix-like platforms. [breaking-change]
⌛ Testing commit a7bbd7d with merge 57cd1c4... |
💔 Test failed - auto-linux-32-opt |
@bors: retry On Sun, Jun 14, 2015 at 10:11 PM, bors notifications@github.com wrote:
|
Closes #25977 The various `stdfoo_raw` methods in std::io now return `io::Result`s, since they may not exist on Windows. They will always return `Ok` on Unix-like platforms. [breaking-change]
I tagged this as stable-regression since it changes the behavior of stdio. |
Closes #25977
The various
stdfoo_raw
methods in std::io now returnio::Result
s,since they may not exist on Windows. They will always return
Ok
onUnix-like platforms.
[breaking-change]