diff --git a/src/error.rs b/src/error.rs index e516a1957a25bc709d34323808933d893eac9a8d..d97c4e7a558b1048871fc2cdc09339a1aaed6516 100644 --- a/src/error.rs +++ b/src/error.rs @@ -7,6 +7,7 @@ use std::fmt; #[cfg(unix)] use nix; +#[cfg(unix)] use char_iter; /// The error type for Rustyline errors that can arise from @@ -15,12 +16,13 @@ use char_iter; pub enum ReadlineError { /// I/O Error Io(io::Error), - /// Chars Error - Char(char_iter::CharsError), /// EOF (Ctrl-d) Eof, /// Ctrl-C Interrupted, + /// Chars Error + #[cfg(unix)] + Char(char_iter::CharsError), /// Unix Error from syscall #[cfg(unix)] Errno(nix::Error), @@ -34,10 +36,11 @@ impl fmt::Display for ReadlineError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ReadlineError::Io(ref err) => err.fmt(f), - ReadlineError::Char(ref err) => err.fmt(f), ReadlineError::Eof => write!(f, "EOF"), ReadlineError::Interrupted => write!(f, "Interrupted"), #[cfg(unix)] + ReadlineError::Char(ref err) => err.fmt(f), + #[cfg(unix)] ReadlineError::Errno(ref err) => write!(f, "Errno: {}", err.errno().desc()), #[cfg(windows)] ReadlineError::WindowResize => write!(f, "WindowResize"), @@ -51,10 +54,11 @@ impl error::Error for ReadlineError { fn description(&self) -> &str { match *self { ReadlineError::Io(ref err) => err.description(), - ReadlineError::Char(ref err) => err.description(), ReadlineError::Eof => "EOF", ReadlineError::Interrupted => "Interrupted", #[cfg(unix)] + ReadlineError::Char(ref err) => err.description(), + #[cfg(unix)] ReadlineError::Errno(ref err) => err.errno().desc(), #[cfg(windows)] ReadlineError::WindowResize => "WindowResize", diff --git a/src/lib.rs b/src/lib.rs index 019a67ad9e3e5d128e2283981a903b8eddb35c51..e8069a231185b4b0ca8a7460c960cb8b255df207 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32,7 +32,6 @@ pub mod error; pub mod history; mod kill_ring; pub mod line_buffer; -mod char_iter; #[macro_use] mod tty; @@ -1093,11 +1092,10 @@ mod test { use history::History; #[cfg(unix)] use completion::Completer; - #[cfg(unix)] - use consts::KeyPress; use State; + #[cfg(unix)] use super::Result; - use tty::{Handle, RawReader}; + use tty::Handle; #[cfg(unix)] fn default_handle() -> Handle { @@ -1178,6 +1176,9 @@ mod test { #[test] #[cfg(unix)] fn complete_line() { + use consts::KeyPress; + use tty::RawReader; + let mut out = ::std::io::sink(); let mut s = init_state(&mut out, "rus", 3, 80); let input = b"\n";