Skip to content

Commit

Permalink
chore(primitives): re-use ruint mask function (#698)
Browse files Browse the repository at this point in the history
Drop duplicate mask method, underline crate ruint already have this method.
  • Loading branch information
rongyi authored and klkvr committed Aug 4, 2024
1 parent a771aba commit 915e461
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
2 changes: 1 addition & 1 deletion crates/primitives/src/signed/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl<const BITS: usize, const LIMBS: usize> fmt::UpperHex for Signed<BITS, LIMBS

impl<const BITS: usize, const LIMBS: usize> Signed<BITS, LIMBS> {
/// Mask for the highest limb.
pub(crate) const MASK: u64 = mask(BITS);
pub(crate) const MASK: u64 = ruint::mask(BITS);

/// Location of the sign bit within the highest limb.
pub(crate) const SIGN_BIT: u64 = sign_bit(BITS);
Expand Down
14 changes: 0 additions & 14 deletions crates/primitives/src/signed/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,3 @@ pub(super) const fn sign_bit(bits: usize) -> u64 {
1 << (bits - 1)
}
}

/// Mask to apply to the highest limb to get the correct number of bits.
#[must_use]
pub(super) const fn mask(bits: usize) -> u64 {
if bits == 0 {
return 0;
}
let bits = bits % 64;
if bits == 0 {
u64::MAX
} else {
(1 << bits) - 1
}
}

0 comments on commit 915e461

Please sign in to comment.