Skip to content
Open
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
21 changes: 0 additions & 21 deletions foyer-common/src/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,6 @@ impl<
{
}

/// Check if the given value is a power of 2.
#[inline(always)]
pub fn is_pow2<U: Unsigned>(v: U) -> bool {
v & (v - U::from(1)) == U::from(0)
}

/// Assert that the given value is a power of 2.
#[inline(always)]
pub fn assert_pow2<U: Unsigned>(v: U) {
assert_eq!(v & (v - U::from(1)), U::from(0), "v: {v}");
}

/// Debug assert that the given value is a power of 2.
#[inline(always)]
pub fn debug_assert_pow2<U: Unsigned>(v: U) {
Expand All @@ -99,15 +87,6 @@ pub fn assert_aligned<U: Unsigned>(align: U, v: U) {
assert!(is_aligned(align, v), "align: {align}, v: {v}");
}

/// Debug assert that the given value is aligned with the given align.
///
/// Note: The given align must be a power of 2.
#[inline(always)]
pub fn debug_assert_aligned<U: Unsigned>(align: U, v: U) {
debug_assert_pow2(align);
debug_assert!(is_aligned(align, v), "align: {align}, v: {v}");
}

/// Align up the given value with the given align.
///
/// Note: The given align must be a power of 2.
Expand Down
Loading