From 92c144e657ede392d0ae116bab85f197e64a65cd Mon Sep 17 00:00:00 2001 From: pierresy Date: Thu, 19 Nov 2015 09:54:38 +0100 Subject: Updated Cargo.toml and README.md. Using style string don't panic anymore if some specifier are unknown. Tables and Rows are now Indexable. Empty rows are now correctly printed. New lines use "\n" for all platforms except windows (which uses "\r\n"). --- src/cell.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/cell.rs') diff --git a/src/cell.rs b/src/cell.rs index 2fd50d2..31006ff 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -102,9 +102,6 @@ impl Cell { /// * **R** : Bright Red /// * **B** : Bright Blue /// * ... and so on ... - /// - /// # Panic - /// If the spec string is wrong pub fn style_spec(mut self, spec: &str) -> Cell { let mut foreground = false; let mut background = false; @@ -127,7 +124,11 @@ impl Cell { 'W' => color::BRIGHT_WHITE, 'd' => color::BLACK, 'D' => color::BRIGHT_BLACK, - _ => panic!("Unsupported color specifier {}", c) + _ => { // Silently ignore unknown tags + foreground = false; + background = false; + continue; + } }; if foreground { self.style(Attr::ForegroundColor(color)); } else if background { self.style(Attr::BackgroundColor(color)); } @@ -144,8 +145,8 @@ impl Cell { 'c' => self.align(Align::CENTER), 'l' => self.align(Align::LEFT), 'r' => self.align(Align::RIGHT), - 'd' => {/*Default : do nothing*/} - _ => panic!("Unsupported style specifier {}", c) + 'd' => {/* Default : do nothing */} + _ => {/* Silently ignore unknown tags */} } } } -- cgit v1.2.3