From a2141a2011d40c06bfabca14d4d1c21cc15d4b87 Mon Sep 17 00:00:00 2001 From: logaritmisk Date: Wed, 15 Jun 2016 16:14:42 +0200 Subject: [PATCH] Thanks clippy! --- src/bbp.rs | 6 +++--- src/main.rs | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/bbp.rs b/src/bbp.rs index f00aef9..0afd676 100644 --- a/src/bbp.rs +++ b/src/bbp.rs @@ -68,13 +68,13 @@ fn expm(p: f64, ak: f64) -> f64 { for _ in 1..i + 1 { if p >= pt { - r = 16.0 * r; - r = r - (r / ak).trunc() * ak; + r *= 16.0; + r -= (r / ak).trunc() * ak; p -= pt; } - pt = 0.5 * pt; + pt *= 0.5; if pt >= 1.0 { r *= r; diff --git a/src/main.rs b/src/main.rs index 2c5bcd0..99c3cb7 100644 --- a/src/main.rs +++ b/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; }