From 362cb2fec7748c2258b78b51e4d69b6f1c605b67 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Wed, 8 Nov 2023 09:46:14 +0800 Subject: [PATCH] Replace unwrap by `Optin::ok_or` --- src/decode.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/decode.rs b/src/decode.rs index 739d64c..10a8503 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -227,7 +227,10 @@ pub fn hex_decode_with_case( dst: &mut [u8], check_case: CheckCase, ) -> Result<(), Error> { - let len = dst.len().checked_mul(2).unwrap(); + let len = dst + .len() + .checked_mul(2) + .ok_or(Error::InvalidLength(dst.len()))?; if src.len() < len || ((src.len() & 1) != 0) { return Err(Error::InvalidLength(len)); }