From 7aebbe6f9d97e6d763a3274253b325765ffb125b Mon Sep 17 00:00:00 2001 From: Alexey Zinchenko Date: Sun, 7 Mar 2021 13:33:52 +0300 Subject: [PATCH] Small refactoring. --- src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3b4f806..5040692 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,7 +85,7 @@ impl<'a> Shredder<'a> { &file, file_length, absolute_path, - &configuration.rewrite_iterations, + configuration.rewrite_iterations, ); if !configuration.keep_files { @@ -109,7 +109,7 @@ impl<'a> Shredder<'a> { }; } - fn shred_file(file: &File, file_length: u64, absolute_path: &str, iterations: &u8) { + fn shred_file(file: &File, file_length: u64, absolute_path: &str, iterations: u8) { let mut buffer = BufWriter::new(file); let pb = ProgressBar::new(file_length); @@ -118,8 +118,8 @@ impl<'a> Shredder<'a> { .template("{prefix} {spinner:.green} [{elapsed_precise}] [{bar:40.cyan/blue}] {bytes}/{total_bytes} {bytes_per_sec} ({eta})") .progress_chars("#>-")); - for i in 0..*iterations { - pb.set_prefix(&format!("Iteration {}/{}", i + 1, *iterations)); + for i in 0..iterations { + pb.set_prefix(&format!("Iteration {}/{}", i + 1, iterations)); let mut bytes_processed = 0; while bytes_processed < file_length { let bytes_to_write = if file_length - bytes_processed > BATCH_SIZE as u64 { @@ -279,7 +279,7 @@ impl Ord for Verbosity { impl PartialOrd for Verbosity { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.discriminant().cmp(&other.discriminant())) + Some(self.cmp(other)) } }