From 681ff6bde28ba9001ddbd2314023ec6c791bbcdc Mon Sep 17 00:00:00 2001 From: lookbusy1344 Date: Wed, 3 Apr 2024 10:54:40 +0100 Subject: [PATCH] Simplifying the check of Option --- src/hasher.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/hasher.rs b/src/hasher.rs index 5a739a4..30625db 100644 --- a/src/hasher.rs +++ b/src/hasher.rs @@ -14,11 +14,9 @@ const BUFFER_SIZE: usize = 4096 * 8; fn hash_file(filename: &str) -> anyhow::Result> { let filesize = usize::try_from(file_size(filename)?).ok(); - if let Some(size) = filesize { - if size <= BUFFER_SIZE { - // this file is smaller than the buffer size, so we can hash it all at once - return hash_file_whole::(filename); - } + if filesize.map_or(false, |size| size <= BUFFER_SIZE) { + // this file is smaller than the buffer size, so we can hash it all at once + return hash_file_whole::(filename); } let file = File::open(filename)?;