From 2cf731dd42ac0dba2fc4885303ba4e11626ff2eb Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sun, 24 Nov 2019 13:20:48 +0800 Subject: [PATCH] update format --- src/main.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0bb0321..a5cc621 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,9 +68,7 @@ fn main() -> XResult<()> { if options.file_name_list.is_empty() { let boxed_digest = get_digest_by_algorithm(the_algo.as_str(), &options); match boxed_digest { - Some(mut digest) => { - println!("{} - ({})", calc_digest_stdin(&mut *digest)?, the_algo); - }, + Some(mut digest) => println!("{} - ({})", calc_digest_stdin(&mut *digest)?, the_algo), None => match the_algo.as_str() { "SM3" => println!("{} - ({})", hex::encode(Sm3Hash::new(&read_full_stdin()?).get_hash()), the_algo), _ => print_message(MessageType::ERROR, &format!("Unknown algorithm: {}", options.algorithm)), @@ -81,9 +79,7 @@ fn main() -> XResult<()> { let the_fn = f.as_str(); let boxed_digest = get_digest_by_algorithm(the_algo.as_str(), &options); match boxed_digest { - Some(mut digest) => { - println!("{} - {} ({})", calc_file_digest(&mut *digest, the_fn)?, the_fn, the_algo); - }, + Some(mut digest) => println!("{} - {} ({})", calc_file_digest(&mut *digest, the_fn)?, the_fn, the_algo), None => match the_algo.as_str() { "SM3" => println!("{} - {} ({})", hex::encode(Sm3Hash::new(&read_file_full(the_fn)?).get_hash()), the_fn, the_algo), _ => { @@ -120,8 +116,8 @@ fn get_digest_by_algorithm(algo: &str, options: &Options) -> Option Some(Box::new(Ripemd160::new())), "WHIRLPOOL" => Some(Box::new(Whirlpool::new())), - "BLAKE2S" => Some(Box::new(Blake2s::new(if options.blake_len == 0_usize { 32 } else { options.blake_len }))), - "BLAKE2B" => Some(Box::new(Blake2b::new(if options.blake_len == 0_usize { 64 } else { options.blake_len }))), + "BLAKE2S" => Some(Box::new(Blake2s::new(if options.blake_len == 0_usize { 32 } else { options.blake_len }))), + "BLAKE2B" => Some(Box::new(Blake2b::new(if options.blake_len == 0_usize { 64 } else { options.blake_len }))), "MD5" => Some(Box::new(Md5::new())), "SHA1" | "SHA-1" => Some(Box::new(Sha1::new())), "SHA224" | "SHA-224" => Some(Box::new(Sha224::new())),