pub trait IntPow2: Sized {
// Required methods
fn from_pow2(p: Pow2) -> Self;
fn is_aligned(self, p: Pow2) -> bool;
fn align_down(self, p: Pow2) -> Self;
fn align_up_unchecked(self, p: Pow2) -> Self;
fn align_up(self, p: Pow2) -> Option<Self>;
}
Expand description
Integers and pointers that can be represented as powers of 2.
Required Methods§
sourcefn is_aligned(self, p: Pow2) -> bool
fn is_aligned(self, p: Pow2) -> bool
Indicates whether a value of Self
is a multiple of a given power of 2 (is aligned).
sourcefn align_down(self, p: Pow2) -> Self
fn align_down(self, p: Pow2) -> Self
Returns the greatest multiple of p
that is less than or equal to Self
.
sourcefn align_up_unchecked(self, p: Pow2) -> Self
fn align_up_unchecked(self, p: Pow2) -> Self
Returns the smallest multiple of p
is that is greater than or equal to Self
.