Skip to content

Commit

Permalink
use assert
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Jul 12, 2024
1 parent c7ee9c8 commit f9d2e59
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions core/src/mast/serialization/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,19 +245,16 @@ impl MastNodeType {
/// # Panics
/// - Panics if either `left_value` or `right_value` doesn't fit in 30 bits.
fn encode_u32_pair(left_value: u32, right_value: u32) -> u64 {
if left_value.leading_zeros() < 2 {
panic!(
"MastNodeType::encode_u32_pair: left value doesn't fit in 30 bits: {}",
left_value
);
}

if right_value.leading_zeros() < 2 {
panic!(
"MastNodeType::encode_u32_pair: right value doesn't fit in 30 bits: {}",
left_value
);
}
assert!(
left_value.leading_zeros() < 2,
"MastNodeType::encode_u32_pair: left value doesn't fit in 30 bits: {}",
left_value
);
assert!(
right_value.leading_zeros() < 2,
"MastNodeType::encode_u32_pair: right value doesn't fit in 30 bits: {}",
right_value
);

((left_value as u64) << 30) | (right_value as u64)
}
Expand Down

0 comments on commit f9d2e59

Please sign in to comment.