summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Henri Symoneaux <pierre.henri.symoneaux@gmail.com>2019-08-25 20:19:20 +0200
committerPierre-Henri Symoneaux <pierre.henri.symoneaux@gmail.com>2019-08-25 20:19:20 +0200
commit2040ec8190518db84d1651c596950488750ab567 (patch)
treed318f6a8e2b59c5c208f62c92ad9d9cd65d28d3a
parentcb6a033d7a212674c356c1a8365511abe2b4fca9 (diff)
Fixed a few clippy warnings (but not all)
-rw-r--r--src/cell.rs3
-rw-r--r--src/csv.rs6
-rw-r--r--src/format.rs10
-rw-r--r--src/lib.rs6
-rw-r--r--src/row.rs2
-rw-r--r--src/utils.rs14
6 files changed, 20 insertions, 21 deletions
diff --git a/src/cell.rs b/src/cell.rs
index 795c4c7..a60a905 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -231,8 +231,7 @@ impl Cell {
for a in &self.style {
match out.attr(*a) {
Ok(..) | Err(::term::Error::NotSupported) | Err(::term::Error::ColorOutOfRange) => {
- ()
- } // Ignore unsupported atrributes
+ } // Ignore unsupported attributes
Err(e) => return Err(term_error_to_io_error(e)),
};
}
diff --git a/src/csv.rs b/src/csv.rs
index 417e8e6..9c5cd9f 100644
--- a/src/csv.rs
+++ b/src/csv.rs
@@ -83,9 +83,9 @@ impl super::Table {
mod tests {
use crate::{Table, Row, Cell};
- static CSV_S: &'static str = "ABC,DEFG,HIJKLMN\n\
- foobar,bar,foo\n\
- foobar2,bar2,foo2\n";
+ static CSV_S: &str = "ABC,DEFG,HIJKLMN\n\
+ foobar,bar,foo\n\
+ foobar2,bar2,foo2\n";
fn test_table() -> Table {
let mut table = Table::new();
diff --git a/src/format.rs b/src/format.rs
index ddf6713..9339348 100644
--- a/src/format.rs
+++ b/src/format.rs
@@ -60,10 +60,10 @@ impl LineSeparator {
/// and `junc` is the one used for junctions between columns and lines
pub fn new(line: char, junc: char, ljunc: char, rjunc: char) -> LineSeparator {
LineSeparator {
- line: line,
- junc: junc,
- ljunc: ljunc,
- rjunc: rjunc,
+ line,
+ junc,
+ ljunc,
+ rjunc,
}
}
@@ -80,7 +80,7 @@ impl LineSeparator {
if lborder {
out.write_all(Utf8Char::from(self.ljunc).as_bytes())?;
}
- let mut iter = col_width.into_iter().peekable();
+ let mut iter = col_width.iter().peekable();
while let Some(width) = iter.next() {
for _ in 0..width + padding.0 + padding.1 {
out.write_all(Utf8Char::from(self.line).as_bytes())?;
diff --git a/src/lib.rs b/src/lib.rs
index e60a076..753ad86 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -3,7 +3,7 @@
unused_import_braces,
unused_qualifications)]
//! A formatted and aligned table printer written in rust
-//!
+
#[macro_use]
extern crate lazy_static;
@@ -145,7 +145,7 @@ impl<'a> TableSlice<'a> {
.print_line_separator(out, &col_width, LinePosition::Title)?;
}
// Print rows
- let mut iter = self.rows.into_iter().peekable();
+ let mut iter = self.rows.iter().peekable();
while let Some(r) = iter.next() {
height += f(r, out, self.format, &col_width)?;
if iter.peek().is_some() {
@@ -214,7 +214,7 @@ impl Table {
/// Create a table initialized with `rows`
pub fn init(rows: Vec<Row>) -> Table {
Table {
- rows: rows,
+ rows,
titles: Box::new(None),
format: Box::new(*consts::FORMAT_DEFAULT),
}
diff --git a/src/row.rs b/src/row.rs
index 94c0d8e..ccb1914 100644
--- a/src/row.rs
+++ b/src/row.rs
@@ -20,7 +20,7 @@ pub struct Row {
impl Row {
/// Create a new `Row` backed with `cells` vector
pub fn new(cells: Vec<Cell>) -> Row {
- Row { cells: cells }
+ Row { cells }
}
/// Create an row of length `size`, with empty strings stored
diff --git a/src/utils.rs b/src/utils.rs
index f2d89ae..65e87dd 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -7,9 +7,9 @@ use unicode_width::UnicodeWidthStr;
use super::format::Alignment;
#[cfg(any(not(windows), not(feature="win_crlf")))]
-pub static NEWLINE: &'static [u8] = b"\n";
+pub static NEWLINE: &[u8] = b"\n";
#[cfg(all(windows, feature="win_crlf"))]
-pub static NEWLINE: &'static [u8] = b"\r\n";
+pub static NEWLINE: &[u8] = b"\r\n";
/// Internal utility for writing data into a string
pub struct StringWriter {
@@ -114,10 +114,10 @@ mod tests {
#[test]
fn string_writer() {
let mut out = StringWriter::new();
- out.write("foo".as_bytes()).unwrap();
- out.write(" ".as_bytes()).unwrap();
- out.write("".as_bytes()).unwrap();
- out.write("bar".as_bytes()).unwrap();
+ out.write_all(b"foo").unwrap();
+ out.write_all(b" ").unwrap();
+ out.write_all(b"").unwrap();
+ out.write_all(b"bar").unwrap();
assert_eq!(out.as_string(), "foo bar");
}
@@ -162,7 +162,7 @@ mod tests {
#[test]
fn utf8_error() {
let mut out = StringWriter::new();
- let res = out.write_all(&vec![0, 255]);
+ let res = out.write_all(&[0, 255]);
assert!(res.is_err());
}
}