Skip to content

Commit

Permalink
Replace unwrap by Optin::ok_or
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Nov 8, 2023
1 parent 8e22de4 commit 362cb2f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit 362cb2f

Please sign in to comment.