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