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:
parent
e546452727
commit
dc921c1433
1 changed files with 10 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue