Thanks clippy!
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -52,7 +52,7 @@ fn main() {
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
if matches.free.len() == 0 {
|
||||
if matches.free.is_empty() {
|
||||
println!("Missing operand: INPUT OUTPUT");
|
||||
println!("Try `{} --help` for more information.", program);
|
||||
std::process::exit(1);
|
||||
@@ -62,16 +62,16 @@ fn main() {
|
||||
let input = &matches.free[0];
|
||||
let output = &matches.free[1];
|
||||
|
||||
compress(&input, &output);
|
||||
compress(input, output);
|
||||
} else if matches.opt_present("d") {
|
||||
let input = &matches.free[0];
|
||||
let output = &matches.free[1];
|
||||
|
||||
extract(&input, &output)
|
||||
extract(input, output)
|
||||
}
|
||||
}
|
||||
|
||||
fn compress(input: &String, output: &String) {
|
||||
fn compress(input: &str, output: &str) {
|
||||
let mut output_file = fs::File::create(output).unwrap();
|
||||
|
||||
let input_file = fs::File::open(input).unwrap();
|
||||
@@ -104,7 +104,7 @@ fn compress(input: &String, output: &String) {
|
||||
}
|
||||
}
|
||||
|
||||
fn extract(input: &String, output: &String) {
|
||||
fn extract(input: &str, output: &str) {
|
||||
let mut input_file = fs::File::open(input).unwrap();
|
||||
let n_bytes = input_file.metadata().unwrap().len() as u64;
|
||||
|
||||
@@ -118,7 +118,7 @@ fn extract(input: &String, output: &String) {
|
||||
loop {
|
||||
let size = input_file.read(&mut buf).unwrap();
|
||||
|
||||
if size <= 0 {
|
||||
if size == 0 {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user