Convert VarError to io::Error (#41)

This commit is contained in:
Jeremy Soller 2016-07-30 08:37:13 -06:00 committed by ticki
parent f9928bd6fe
commit a3cc227620
1 changed files with 2 additions and 1 deletions

View File

@ -21,7 +21,8 @@ pub fn is_tty<T: AsRawFd>(_stream: T) -> bool {
#[cfg(target_os = "redox")]
pub fn get_tty() -> io::Result<fs::File> {
use std::env;
fs::OpenOptions::new().read(true).write(true).open(try!(env::var("TTY")))
let tty = try!(env::var("TTY").map_err(|x| io::Error::new(io::ErrorKind::NotFound, x)));
fs::OpenOptions::new().read(true).write(true).open(tty)
}
/// Get the TTY device.