Skip to content

Commit fc37072

Browse files
committedNov 30, 2022
follow some cargo clippy warnings
1 parent dbef12c commit fc37072

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed
 

‎build.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::process::Command;
22

33
fn main() {
4-
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap();
4+
let output = Command::new("git").args(["rev-parse", "HEAD"]).output().unwrap();
55
let git_commit_hash = String::from_utf8(output.stdout).unwrap();
66
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", git_commit_hash);
77
let output = Command::new("git")
8-
.args(&["log", "-1", "--date=iso-strict", "--format=%cd"])
8+
.args(["log", "-1", "--date=iso-strict", "--format=%cd"])
99
.output()
1010
.unwrap();
1111
let git_commit_date = String::from_utf8(output.stdout).unwrap();

‎src/io.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::io::{BufRead, BufReader, BufWriter};
44
use std::str::FromStr;
55

66
#[allow(non_camel_case_types)]
7-
#[derive(Debug, PartialEq, Clone, Copy)]
7+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
88
pub enum LineFeed {
99
LF,
1010
LF_CRLF,
@@ -20,15 +20,15 @@ impl FromStr for LineFeed {
2020
type Err = ();
2121
fn from_str(s: &str) -> Result<Self, Self::Err> {
2222
match s {
23-
"LF" => return Result::Ok(LineFeed::LF),
24-
"LF_CRLF" => return Result::Ok(LineFeed::LF_CRLF),
23+
"LF" => Result::Ok(LineFeed::LF),
24+
"LF_CRLF" => Result::Ok(LineFeed::LF_CRLF),
2525
_ => Err(()),
2626
}
2727
}
2828
}
2929

3030
pub fn reader(file_name: &str) -> BufReader<File> {
31-
let file = match File::open(&file_name) {
31+
let file = match File::open(file_name) {
3232
Ok(file) => file,
3333
Err(e) => {
3434
panic!("An error occurred while opening file {}: {}", file_name, e);
@@ -45,7 +45,7 @@ pub fn read_line_with_bytes(reader: &mut dyn BufRead, bytes: usize, feed: LineFe
4545
match read_line_with_linefeed(reader, &mut buf, feed) {
4646
Ok(0) => break,
4747
Ok(n) => {
48-
if !buf.ends_with("\n") {
48+
if !buf.ends_with('\n') {
4949
buf += "\n";
5050
}
5151
current_size += n;
@@ -66,7 +66,7 @@ pub fn read_line_with_bytes(reader: &mut dyn BufRead, bytes: usize, feed: LineFe
6666
}
6767

6868
pub fn writer(file_name: &str) -> BufWriter<File> {
69-
let file = match File::create(&file_name) {
69+
let file = match File::create(file_name) {
7070
Ok(file) => file,
7171
Err(e) => {
7272
panic!("An error occurred while creating file {}: {}", file_name, e);
@@ -75,7 +75,7 @@ pub fn writer(file_name: &str) -> BufWriter<File> {
7575
BufWriter::new(file)
7676
}
7777

78-
pub fn read_line_with_linefeed(reader: &mut dyn BufRead, buf: &mut String, feed: LineFeed) -> std::io::Result<usize> {
78+
pub fn read_line_with_linefeed(reader: &mut dyn BufRead, buf: &mut String, feed: LineFeed) -> std::result::Result<usize, std::io::Error> {
7979
let mut sz = 0;
8080
loop {
8181
let mut tbuf = String::new();
@@ -91,7 +91,7 @@ pub fn read_line_with_linefeed(reader: &mut dyn BufRead, buf: &mut String, feed:
9191
Err(e) => return Err(e),
9292
}
9393
}
94-
return Ok(sz);
94+
Ok(sz)
9595
}
9696

9797
#[test]

‎src/shuffler/shuffle.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct TmpFile {
1717

1818
pub fn shuffle(conf: &Config) {
1919
let mut reader_dyn: Rc<RefCell<dyn BufRead>> = match &conf.source {
20-
Some(source) => Rc::new(RefCell::new(io::reader(&source.first().unwrap()))),
20+
Some(source) => Rc::new(RefCell::new(io::reader(source.first().unwrap()))),
2121
None => Rc::new(RefCell::new(BufReader::new(stdin()))),
2222
};
2323
let writer_dyn: Rc<RefCell<dyn Write>> = match &conf.destination {
@@ -69,7 +69,7 @@ pub fn shuffle(conf: &Config) {
6969
}
7070
tmp_files.push(TmpFile {
7171
remaining_row_count: rows.len(),
72-
file: file,
72+
file,
7373
});
7474
total_rows += rows.len();
7575
}

0 commit comments

Comments
 (0)