summaryrefslogtreecommitdiffstats
path: root/src/cell.rs
diff options
context:
space:
mode:
authorPierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com>2017-06-05 15:34:54 +0200
committerPierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com>2017-06-05 16:31:04 +0200
commit4e36ac179fc5341b35221018573e265a1f1a0a53 (patch)
tree629b1332d2600cafd9292c4426c85de04624108d /src/cell.rs
parent14dcf5f9615eeafb8eb7c20732f55d41d1045884 (diff)
Fixed lint (+clippy) warnings and line endings
Added some lint rustc checks and fixed warnings. Fixed some clippy warnings & errors Converted remaining CRLF line endings to LF
Diffstat (limited to 'src/cell.rs')
-rw-r--r--src/cell.rs89
1 files changed, 44 insertions, 45 deletions
diff --git a/src/cell.rs b/src/cell.rs
index 18aadd0..fd0e0f0 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -23,7 +23,7 @@ impl Cell {
/// Create a new `Cell` initialized with content from `string`.
/// Text alignment in cell is configurable with the `align` argument
pub fn new_align(string: &str, align: Alignment) -> Cell {
- let content: Vec<String> = string.lines().map(|ref x| x.to_string()).collect();
+ let content: Vec<String> = string.lines().map(|x| x.to_string()).collect();
let mut width = 0;
for cont in &content {
let l = UnicodeWidthStr::width(&cont[..]);
@@ -109,29 +109,29 @@ impl Cell {
let mut background = false;
for c in spec.chars() {
if foreground || background {
- let color = match c {
- 'r' => color::RED,
- 'R' => color::BRIGHT_RED,
- 'b' => color::BLUE,
- 'B' => color::BRIGHT_BLUE,
- 'g' => color::GREEN,
- 'G' => color::BRIGHT_GREEN,
- 'y' => color::YELLOW,
- 'Y' => color::BRIGHT_YELLOW,
- 'c' => color::CYAN,
- 'C' => color::BRIGHT_CYAN,
- 'm' => color::MAGENTA,
- 'M' => color::BRIGHT_MAGENTA,
- 'w' => color::WHITE,
- 'W' => color::BRIGHT_WHITE,
- 'd' => color::BLACK,
- 'D' => color::BRIGHT_BLACK,
+ let color = match c {
+ 'r' => color::RED,
+ 'R' => color::BRIGHT_RED,
+ 'b' => color::BLUE,
+ 'B' => color::BRIGHT_BLUE,
+ 'g' => color::GREEN,
+ 'G' => color::BRIGHT_GREEN,
+ 'y' => color::YELLOW,
+ 'Y' => color::BRIGHT_YELLOW,
+ 'c' => color::CYAN,
+ 'C' => color::BRIGHT_CYAN,
+ 'm' => color::MAGENTA,
+ 'M' => color::BRIGHT_MAGENTA,
+ 'w' => color::WHITE,
+ 'W' => color::BRIGHT_WHITE,
+ 'd' => color::BLACK,
+ 'D' => color::BRIGHT_BLACK,
_ => {
// Silently ignore unknown tags
foreground = false;
background = false;
continue;
- }
+ }
};
if foreground {
self.style(Attr::ForegroundColor(color));
@@ -141,21 +141,20 @@ impl Cell {
foreground = false;
background = false;
} else {
- match c {
- 'F' => foreground = true,
- 'B' => background = true,
- 'b' => self.style(Attr::Bold),
- 'i' => self.style(Attr::Italic(true)),
- 'u' => self.style(Attr::Underline(true)),
- 'c' => self.align(Alignment::CENTER),
- 'l' => self.align(Alignment::LEFT),
- 'r' => self.align(Alignment::RIGHT),
- 'd' => { /* Default : do nothing */ }
- _ => { /* Silently ignore unknown tags */ }
+ match c {
+ 'F' => foreground = true,
+ 'B' => background = true,
+ 'b' => self.style(Attr::Bold),
+ 'i' => self.style(Attr::Italic(true)),
+ 'u' => self.style(Attr::Underline(true)),
+ 'c' => self.align(Alignment::CENTER),
+ 'l' => self.align(Alignment::LEFT),
+ 'r' => self.align(Alignment::RIGHT),
+ _ => { /* Silently ignore unknown tags */ }
}
}
}
- return self;
+ self
}
/// Return the height of the cell
@@ -195,27 +194,27 @@ impl Cell {
skip_right_fill: bool)
-> Result<(), Error> {
for a in &self.style {
- match out.attr(a.clone()) {
+ match out.attr(*a) {
Ok(..) |
Err(::term::Error::NotSupported) |
- Err(::term::Error::ColorOutOfRange) => (), // Ignore unsupported atrributes
- Err(e) => return Err(term_error_to_io_error(e)),
+ Err(::term::Error::ColorOutOfRange) => (), // Ignore unsupported atrributes
+ Err(e) => return Err(term_error_to_io_error(e)),
};
}
try!(self.print(out, idx, col_width, skip_right_fill));
- match out.reset() {
+ match out.reset() {
Ok(..) |
Err(::term::Error::NotSupported) |
- Err(::term::Error::ColorOutOfRange) => Ok(()),
- Err(e) => Err(term_error_to_io_error(e)),
+ Err(::term::Error::ColorOutOfRange) => Ok(()),
+ Err(e) => Err(term_error_to_io_error(e)),
}
}
}
fn term_error_to_io_error(te: ::term::Error) -> Error {
- match te {
- ::term::Error::Io(why) => why,
- _ => Error::new(::std::io::ErrorKind::Other, te),
+ match te {
+ ::term::Error::Io(why) => why,
+ _ => Error::new(::std::io::ErrorKind::Other, te),
}
}
@@ -257,7 +256,7 @@ impl Default for Cell {
/// ```
/// Value must implement the `std::string::ToString` trait
///
-/// For details about style specifier syntax, check doc for [Cell::style_spec](cell/struct.Cell.html#method.style_spec) method
+/// For details about style specifier syntax, check doc for [`Cell::style_spec`](cell/struct.Cell.html#method.style_spec) method
/// # Example
/// ```
/// # #[macro_use] extern crate prettytable;
@@ -271,10 +270,10 @@ impl Default for Cell {
/// # }
/// ```
#[macro_export]
-macro_rules! cell {
- () => ($crate::cell::Cell::default());
- ($value:expr) => ($crate::cell::Cell::new(&$value.to_string()));
- ($style:ident -> $value:expr) => (cell!($value).style_spec(stringify!($style)));
+macro_rules! cell {
+ () => ($crate::cell::Cell::default());
+ ($value:expr) => ($crate::cell::Cell::new(&$value.to_string()));
+ ($style:ident -> $value:expr) => (cell!($value).style_spec(stringify!($style)));
}
#[cfg(test)]