summaryrefslogtreecommitdiffstats
path: root/src/row.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/row.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/row.rs')
-rw-r--r--src/row.rs39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/row.rs b/src/row.rs
index 4e0975d..69647ce 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -32,6 +32,11 @@ impl Row {
self.cells.len()
}
+ /// Check if the row is empty (has no cell)
+ pub fn is_empty(&self) -> bool {
+ self.cells.is_empty()
+ }
+
/// Get the height of this row
pub fn get_height(&self) -> usize {
let mut height = 1; // Minimum height must be 1 to print empty rows
@@ -95,12 +100,12 @@ impl Row {
}
/// Returns an immutable iterator over cells
- pub fn iter<'a>(&'a self) -> Iter<'a, Cell> {
+ pub fn iter(&self) -> Iter<Cell> {
self.cells.iter()
}
/// Returns an mutable iterator over cells
- pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, Cell> {
+ pub fn iter_mut(&mut self) -> IterMut<Cell> {
self.cells.iter_mut()
}
@@ -117,14 +122,14 @@ impl Row {
try!(format.print_column_separator(out, ColumnPosition::Left));
let (lp, rp) = format.get_padding();
for j in 0..col_width.len() {
- try!(out.write(&vec![' ' as u8; lp]));
+ try!(out.write_all(&vec![b' '; lp]));
let skip_r_fill = (j == col_width.len() - 1) &&
format.get_column_separator(ColumnPosition::Right).is_none();
- match self.get_cell(j) {
- Some(ref c) => try!(f(c, out, i, col_width[j], skip_r_fill)),
- None => try!(f(&Cell::default(), out, i, col_width[j], skip_r_fill)),
+ match self.get_cell(j) {
+ Some(c) => try!(f(c, out, i, col_width[j], skip_r_fill)),
+ None => try!(f(&Cell::default(), out, i, col_width[j], skip_r_fill)),
};
- try!(out.write(&vec![' ' as u8; rp]));
+ try!(out.write_all(&vec![b' '; rp]));
if j < col_width.len() - 1 {
try!(format.print_column_separator(out, ColumnPosition::Intern));
}
@@ -229,15 +234,15 @@ impl<'a> IntoIterator for &'a mut Row {
/// # }
/// ```
///
-/// 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
#[macro_export]
-macro_rules! row {
- (($($out:tt)*); $value:expr) => (vec![$($out)* cell!($value)]);
- (($($out:tt)*); $value:expr, $($n:tt)*) => (row!(($($out)* cell!($value),); $($n)*));
- (($($out:tt)*); $style:ident -> $value:expr) => (vec![$($out)* cell!($style -> $value)]);
- (($($out:tt)*); $style:ident -> $value:expr, $($n: tt)*) => (row!(($($out)* cell!($style -> $value),); $($n)*));
-
- ($($content:expr), *) => ($crate::row::Row::new(vec![$(cell!($content)), *]));
- ($style:ident => $($content:expr), *) => ($crate::row::Row::new(vec![$(cell!($style -> $content)), *]));
- ($($content:tt)*) => ($crate::row::Row::new(row!((); $($content)*)));
+macro_rules! row {
+ (($($out:tt)*); $value:expr) => (vec![$($out)* cell!($value)]);
+ (($($out:tt)*); $value:expr, $($n:tt)*) => (row!(($($out)* cell!($value),); $($n)*));
+ (($($out:tt)*); $style:ident -> $value:expr) => (vec![$($out)* cell!($style -> $value)]);
+ (($($out:tt)*); $style:ident -> $value:expr, $($n: tt)*) => (row!(($($out)* cell!($style -> $value),); $($n)*));
+
+ ($($content:expr), *) => ($crate::row::Row::new(vec![$(cell!($content)), *]));
+ ($style:ident => $($content:expr), *) => ($crate::row::Row::new(vec![$(cell!($style -> $content)), *]));
+ ($($content:tt)*) => ($crate::row::Row::new(row!((); $($content)*)));
}