Skip to content

Commit

Permalink
Use unpack_unverified in from
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez committed Nov 24, 2023
1 parent 9dfc2fb commit 7605bf4
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions sdk/src/types/block/output/output_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,11 @@ impl OutputId {
#[cfg(feature = "serde")]
crate::string_serde_impl!(OutputId);

#[allow(clippy::fallible_impl_from)]
impl From<[u8; Self::LENGTH]> for OutputId {
fn from(bytes: [u8; Self::LENGTH]) -> Self {
let (transaction_id, index) = bytes.split_at(TransactionId::LENGTH);

Self::new(
// Unwrap is fine because size is already known and valid.
TransactionId::new(transaction_id.try_into().unwrap()),
// Unwrap is fine because size is already known and valid.
u16::from_le_bytes(index.try_into().unwrap()),
)
// Unwrap is fine because size is already known and valid.
Self::unpack_unverified(bytes).unwrap()
}
}

Expand Down

0 comments on commit 7605bf4

Please sign in to comment.