1
Fork 0

Add .isatty() method to StdReader

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:
Kevin Ballard 2014-05-20 20:04:16 -07:00
parent e546452727
commit dc921c1433

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 {