Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(primitives): re-use ruint mask function #698

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}