Skip to content

Commit

Permalink
Replaced unsafe unwrap
Browse files Browse the repository at this point in the history
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
  • Loading branch information
Artemkaaas committed Jan 9, 2024
1 parent 7c4d90f commit 1e0f32b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/data_types/nonce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ impl<'a> Deserialize<'a> for Nonce {
let mut vec = Vec::new();

while let Ok(Some(Value::Number(elem))) = seq.next_element() {
vec.push(elem.as_u64().unwrap() as u8);
vec.push(
elem.as_u64()
.ok_or_else(|| E::Error::custom("invalid nonce"))?
as u8,
);
}

Nonce::from_bytes(&vec).map_err(E::Error::custom)
Expand Down

0 comments on commit 1e0f32b

Please sign in to comment.