auto merge of #14315 : kballard/rust/stdreader_isatty, r=alexcrichton

StdWriter has .isatty(). StdReader can trivially vend the same function,
and someone asked today on IRC how to call isatty() on stdin.
This commit is contained in:
bors 2014-05-21 01:11:25 -07:00
commit 4605232f26

View File

@ -290,6 +290,16 @@ pub struct StdReader {
inner: StdSource
}
impl StdReader {
/// Returns whether this stream is attached to a TTY instance or not.
pub fn isatty(&self) -> bool {
match self.inner {
TTY(..) => true,
File(..) => false,
}
}
}
impl Reader for StdReader {
fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
let ret = match self.inner {