Skip to content

Commit 2040ec8

Browse files
committed
Fixed a few clippy warnings (but not all)
1 parent cb6a033 commit 2040ec8

File tree

6 files changed

+20
-21
lines changed

6 files changed

+20
-21
lines changed

src/cell.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ impl Cell {
231231
for a in &self.style {
232232
match out.attr(*a) {
233233
Ok(..) | Err(::term::Error::NotSupported) | Err(::term::Error::ColorOutOfRange) => {
234-
()
235-
} // Ignore unsupported atrributes
234+
} // Ignore unsupported attributes
236235
Err(e) => return Err(term_error_to_io_error(e)),
237236
};
238237
}

src/csv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ impl super::Table {
8383
mod tests {
8484
use crate::{Table, Row, Cell};
8585

86-
static CSV_S: &'static str = "ABC,DEFG,HIJKLMN\n\
87-
foobar,bar,foo\n\
88-
foobar2,bar2,foo2\n";
86+
static CSV_S: &str = "ABC,DEFG,HIJKLMN\n\
87+
foobar,bar,foo\n\
88+
foobar2,bar2,foo2\n";
8989

9090
fn test_table() -> Table {
9191
let mut table = Table::new();

src/format.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ impl LineSeparator {
6060
/// and `junc` is the one used for junctions between columns and lines
6161
pub fn new(line: char, junc: char, ljunc: char, rjunc: char) -> LineSeparator {
6262
LineSeparator {
63-
line: line,
64-
junc: junc,
65-
ljunc: ljunc,
66-
rjunc: rjunc,
63+
line,
64+
junc,
65+
ljunc,
66+
rjunc,
6767
}
6868
}
6969

@@ -80,7 +80,7 @@ impl LineSeparator {
8080
if lborder {
8181
out.write_all(Utf8Char::from(self.ljunc).as_bytes())?;
8282
}
83-
let mut iter = col_width.into_iter().peekable();
83+
let mut iter = col_width.iter().peekable();
8484
while let Some(width) = iter.next() {
8585
for _ in 0..width + padding.0 + padding.1 {
8686
out.write_all(Utf8Char::from(self.line).as_bytes())?;

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
unused_import_braces,
44
unused_qualifications)]
55
//! A formatted and aligned table printer written in rust
6-
//!
6+
77
#[macro_use]
88
extern crate lazy_static;
99

@@ -145,7 +145,7 @@ impl<'a> TableSlice<'a> {
145145
.print_line_separator(out, &col_width, LinePosition::Title)?;
146146
}
147147
// Print rows
148-
let mut iter = self.rows.into_iter().peekable();
148+
let mut iter = self.rows.iter().peekable();
149149
while let Some(r) = iter.next() {
150150
height += f(r, out, self.format, &col_width)?;
151151
if iter.peek().is_some() {
@@ -214,7 +214,7 @@ impl Table {
214214
/// Create a table initialized with `rows`
215215
pub fn init(rows: Vec<Row>) -> Table {
216216
Table {
217-
rows: rows,
217+
rows,
218218
titles: Box::new(None),
219219
format: Box::new(*consts::FORMAT_DEFAULT),
220220
}

src/row.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub struct Row {
2020
impl Row {
2121
/// Create a new `Row` backed with `cells` vector
2222
pub fn new(cells: Vec<Cell>) -> Row {
23-
Row { cells: cells }
23+
Row { cells }
2424
}
2525

2626
/// Create an row of length `size`, with empty strings stored

src/utils.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use unicode_width::UnicodeWidthStr;
77
use super::format::Alignment;
88

99
#[cfg(any(not(windows), not(feature="win_crlf")))]
10-
pub static NEWLINE: &'static [u8] = b"\n";
10+
pub static NEWLINE: &[u8] = b"\n";
1111
#[cfg(all(windows, feature="win_crlf"))]
12-
pub static NEWLINE: &'static [u8] = b"\r\n";
12+
pub static NEWLINE: &[u8] = b"\r\n";
1313

1414
/// Internal utility for writing data into a string
1515
pub struct StringWriter {
@@ -114,10 +114,10 @@ mod tests {
114114
#[test]
115115
fn string_writer() {
116116
let mut out = StringWriter::new();
117-
out.write("foo".as_bytes()).unwrap();
118-
out.write(" ".as_bytes()).unwrap();
119-
out.write("".as_bytes()).unwrap();
120-
out.write("bar".as_bytes()).unwrap();
117+
out.write_all(b"foo").unwrap();
118+
out.write_all(b" ").unwrap();
119+
out.write_all(b"").unwrap();
120+
out.write_all(b"bar").unwrap();
121121
assert_eq!(out.as_string(), "foo bar");
122122
}
123123

@@ -162,7 +162,7 @@ mod tests {
162162
#[test]
163163
fn utf8_error() {
164164
let mut out = StringWriter::new();
165-
let res = out.write_all(&vec![0, 255]);
165+
let res = out.write_all(&[0, 255]);
166166
assert!(res.is_err());
167167
}
168168
}

0 commit comments

Comments
 (0)