summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2016-01-11 22:19:22 +0100
committerpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2016-01-11 22:20:06 +0100
commit2360c7b4cd53c7bdfd8cdd630db7c4393d828399 (patch)
treedcdeaf8dabccf2f85fa536f5e43a1aa0916db136
parent74f15acde6f32f85a06aeddd4e49dbaf5bb20af3 (diff)
Fixed windows issue for pull request #16
-rw-r--r--Cargo.toml2
-rw-r--r--src/cell.rs14
-rw-r--r--src/lib.rs7
3 files changed, 12 insertions, 11 deletions
diff --git a/Cargo.toml b/Cargo.toml
index dd922db..8954c84 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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());
diff --git a/src/lib.rs b/src/lib.rs
index 4ebb382..20b2389 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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);
+ }
}
}