pub struct NonZeroPow2Usize(/* private fields */);Expand description
An integer that is known to be a power of two with nonzero exponent.
The integer is equal to 2^n for some n > 0.
The integer is strictly greater than 1.
Implementations§
Source§impl NonZeroPow2Usize
impl NonZeroPow2Usize
Sourcepub const fn new_unchecked(n: usize) -> Self
pub const fn new_unchecked(n: usize) -> Self
Sourcepub const fn log2(self) -> NonZeroU32
pub const fn log2(self) -> NonZeroU32
Return the binary logarithm of the value.
The integer is equal to 2^n for some n > 0. Return n.
Sourcepub const fn mul2(self) -> Self
pub const fn mul2(self) -> Self
Multiply the value by two. Return the next power of two.
The integer is equal to 2^n for some n > 0. Return 2^(n + 1).
Sourcepub const fn checked_div2(self) -> Option<Self>
pub const fn checked_div2(self) -> Option<Self>
Divide the value by two. Return the previous power of two with nonzero exponent, if it exists.
- If the integer is equal to 2^(n + 1) for some n > 0, then return
Some(2^n). - If the integer is equal to 2^1, then return
None.
Trait Implementations§
Source§impl Clone for NonZeroPow2Usize
impl Clone for NonZeroPow2Usize
Source§fn clone(&self) -> NonZeroPow2Usize
fn clone(&self) -> NonZeroPow2Usize
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NonZeroPow2Usize
impl Debug for NonZeroPow2Usize
Source§impl Display for NonZeroPow2Usize
impl Display for NonZeroPow2Usize
Source§impl From<NonZeroPow2Usize> for Pow2Usize
impl From<NonZeroPow2Usize> for Pow2Usize
Source§fn from(value: NonZeroPow2Usize) -> Self
fn from(value: NonZeroPow2Usize) -> Self
Converts to this type from the input type.
Source§impl FromStr for NonZeroPow2Usize
impl FromStr for NonZeroPow2Usize
Source§impl Hash for NonZeroPow2Usize
impl Hash for NonZeroPow2Usize
Source§impl Ord for NonZeroPow2Usize
impl Ord for NonZeroPow2Usize
Source§fn cmp(&self, other: &NonZeroPow2Usize) -> Ordering
fn cmp(&self, other: &NonZeroPow2Usize) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for NonZeroPow2Usize
impl PartialEq for NonZeroPow2Usize
Source§impl PartialOrd for NonZeroPow2Usize
impl PartialOrd for NonZeroPow2Usize
impl Copy for NonZeroPow2Usize
impl Eq for NonZeroPow2Usize
impl StructuralPartialEq for NonZeroPow2Usize
Auto Trait Implementations§
impl Freeze for NonZeroPow2Usize
impl RefUnwindSafe for NonZeroPow2Usize
impl Send for NonZeroPow2Usize
impl Sync for NonZeroPow2Usize
impl Unpin for NonZeroPow2Usize
impl UnwindSafe for NonZeroPow2Usize
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more