diff options
author | pierresy <pierre-henri.symoneaux@alcatel-lucent.com> | 2016-01-11 22:19:22 +0100 |
---|---|---|
committer | pierresy <pierre-henri.symoneaux@alcatel-lucent.com> | 2016-01-11 22:20:06 +0100 |
commit | 2360c7b4cd53c7bdfd8cdd630db7c4393d828399 (patch) | |
tree | dcdeaf8dabccf2f85fa536f5e43a1aa0916db136 | |
parent | 74f15acde6f32f85a06aeddd4e49dbaf5bb20af3 (diff) |
Fixed windows issue for pull request #16
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/cell.rs | 14 | ||||
-rw-r--r-- | src/lib.rs | 7 |
3 files changed, 12 insertions, 11 deletions
@@ -1,7 +1,7 @@ [package]
name = "prettytable-rs"
-version = "0.5.1"
+version = "0.5.2"
description = "A library for printing pretty formatted tables in terminal"
homepage = "https://github.com/phsym/prettytable-rs"
repository = "https://github.com/phsym/prettytable-rs"
diff --git a/src/cell.rs b/src/cell.rs index 7032a7b..32aeeeb 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -187,7 +187,12 @@ 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()).map_err(term_error_to_io_error));
+ match out.attr(a.clone()) {
+ Ok(ok) => ok,
+ Err(::term::Error::NotSupported) => (), // Ignore unsupported atrributes
+ Err(::term::Error::Io(why)) => return Err(why),
+ Err(e) => return Err(Error::new(::std::io::ErrorKind::Other, e))
+ };
}
try!(self.print(out, idx, col_width));
try!(out.reset().map_err(term_error_to_io_error));
@@ -195,13 +200,6 @@ impl Cell { }
}
-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());
@@ -142,10 +142,13 @@ impl <'a> TableSlice<'a> { /// # Panic
/// Panic if writing to standard output fails
pub fn printstd(&self) {
- match stdout() {
+ let r = match stdout() {
Some(mut o) => self.print_term(&mut *o),
None => self.print(&mut io::stdout()),
- }.ok().expect("Cannot print table to standard output");
+ };
+ if let Err(e) = r {
+ panic!("Cannot print table to standard output : {}", e);
+ }
}
}
|