diff options
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/cell.rs | 11 |
2 files changed, 10 insertions, 3 deletions
@@ -20,4 +20,4 @@ name = "prettytable" [dependencies]
unicode-width = "^0.1"
-term = "^0.2"
+term = "^0.4"
diff --git a/src/cell.rs b/src/cell.rs index 61bd0d5..7032a7b 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -187,14 +187,21 @@ impl Cell { /// Apply style then call `print` to print the cell into a terminal
pub fn print_term<T: Terminal+?Sized>(&self, out: &mut T, idx: usize, col_width: usize) -> Result<(), Error> {
for a in &self.style {
- try!(out.attr(a.clone()));
+ try!(out.attr(a.clone()).map_err(term_error_to_io_error));
}
try!(self.print(out, idx, col_width));
- try!(out.reset());
+ try!(out.reset().map_err(term_error_to_io_error));
return Ok(());
}
}
+fn term_error_to_io_error(te: ::term::Error) -> Error {
+ match te {
+ ::term::Error::Io(why) => why,
+ _ => Error::new(::std::io::ErrorKind::Other, te),
+ }
+}
+
impl <'a, T: ToString> From<&'a T> for Cell {
fn from(f: &T) -> Cell {
return Cell::new(&f.to_string());
|