pub struct PowerOfTwo(/* private fields */);Implementations§
Source§impl PowerOfTwo
impl PowerOfTwo
pub const P0: Self
pub const V1: Self = Self::P0
pub const P1: Self
pub const V2: Self = Self::P1
pub const P2: Self
pub const V4: Self = Self::P2
pub const P3: Self
pub const V8: Self = Self::P3
pub const P4: Self
pub const V16: Self = Self::P4
pub const P5: Self
pub const V32: Self = Self::P5
pub const P6: Self
pub const V64: Self = Self::P6
pub const P7: Self
pub const V128: Self = Self::P7
pub const P8: Self
pub const V256: Self = Self::P8
pub const P9: Self
pub const V512: Self = Self::P9
pub const P10: Self
pub const V1024: Self = Self::P10
pub const P11: Self
pub const V2048: Self = Self::P11
pub const P12: Self
pub const V4096: Self = Self::P12
pub const P13: Self
pub const V8192: Self = Self::P13
pub const P14: Self
pub const V16384: Self = Self::P14
pub const P15: Self
pub const V32768: Self = Self::P15
pub const P16: Self
pub const V65536: Self = Self::P16
pub const P17: Self
pub const V131072: Self = Self::P17
pub const P18: Self
pub const V262144: Self = Self::P18
pub const P19: Self
pub const V524288: Self = Self::P19
pub const P20: Self
pub const V1048576: Self = Self::P20
pub const P21: Self
pub const V2097152: Self = Self::P21
pub const P22: Self
pub const V4194304: Self = Self::P22
pub const P23: Self
pub const V8388608: Self = Self::P23
pub const P24: Self
pub const V16777216: Self = Self::P24
pub const P25: Self
pub const V33554432: Self = Self::P25
pub const P26: Self
pub const V67108864: Self = Self::P26
pub const P27: Self
pub const V134217728: Self = Self::P27
pub const P28: Self
pub const V268435456: Self = Self::P28
pub const P29: Self
pub const V536870912: Self = Self::P29
pub const P30: Self
pub const V1073741824: Self = Self::P30
pub const P31: Self
pub const V2147483648: Self = Self::P31
Source§impl PowerOfTwo
impl PowerOfTwo
pub const P32: Self
pub const V4294967296: Self = Self::P32
pub const P33: Self
pub const V8589934592: Self = Self::P33
pub const P34: Self
pub const V17179869184: Self = Self::P34
pub const P35: Self
pub const V34359738368: Self = Self::P35
pub const P36: Self
pub const V68719476736: Self = Self::P36
pub const P37: Self
pub const V137438953472: Self = Self::P37
pub const P38: Self
pub const V274877906944: Self = Self::P38
pub const P39: Self
pub const V549755813888: Self = Self::P39
pub const P40: Self
pub const V1099511627776: Self = Self::P40
pub const P41: Self
pub const V2199023255552: Self = Self::P41
pub const P42: Self
pub const V4398046511104: Self = Self::P42
pub const P43: Self
pub const V8796093022208: Self = Self::P43
pub const P44: Self
pub const V17592186044416: Self = Self::P44
pub const P45: Self
pub const V35184372088832: Self = Self::P45
pub const P46: Self
pub const V70368744177664: Self = Self::P46
pub const P47: Self
pub const V140737488355328: Self = Self::P47
pub const P48: Self
pub const V281474976710656: Self = Self::P48
pub const P49: Self
pub const V562949953421312: Self = Self::P49
pub const P50: Self
pub const V1125899906842624: Self = Self::P50
pub const P51: Self
pub const V2251799813685248: Self = Self::P51
pub const P52: Self
pub const V4503599627370496: Self = Self::P52
pub const P53: Self
pub const V9007199254740992: Self = Self::P53
pub const P54: Self
pub const V18014398509481984: Self = Self::P54
pub const P55: Self
pub const V36028797018963968: Self = Self::P55
pub const P56: Self
pub const V72057594037927936: Self = Self::P56
pub const P57: Self
pub const V144115188075855872: Self = Self::P57
pub const P58: Self
pub const V288230376151711744: Self = Self::P58
pub const P59: Self
pub const V576460752303423488: Self = Self::P59
pub const P60: Self
pub const V1152921504606846976: Self = Self::P60
pub const P61: Self
pub const V2305843009213693952: Self = Self::P61
pub const P62: Self
pub const V4611686018427387904: Self = Self::P62
pub const P63: Self
pub const V9223372036854775808: Self = Self::P63
Source§impl PowerOfTwo
impl PowerOfTwo
Sourcepub const fn new(value: usize) -> Result<Self, NotPowerOfTwo>
pub const fn new(value: usize) -> Result<Self, NotPowerOfTwo>
Create a new PowerOfTwo if the given value is greater a power of two.
Sourcepub const fn next(value: usize) -> Option<Self>
pub const fn next(value: usize) -> Option<Self>
Return the smallest power of two greater than or equal to value. If the next
power of two is greater than usize::MAX, None is returned.
Sourcepub const unsafe fn new_unchecked(value: NonZeroUsize) -> Self
pub const unsafe fn new_unchecked(value: NonZeroUsize) -> Self
Create a new PowerOfTwo without checking whether the value is a power of two.
§Safety
The value must be a power of two.
Sourcepub const fn into_inner(self) -> NonZeroUsize
pub const fn into_inner(self) -> NonZeroUsize
Consume self and return the inner value.
Sourcepub const fn from_align(layout: &Layout) -> Self
pub const fn from_align(layout: &Layout) -> Self
Construct self from the alignment in layout.
Sourcepub const fn alignment_of<T>() -> Self
pub const fn alignment_of<T>() -> Self
Return the alignment of T as a power of two.
Sourcepub const fn arg_mod(self, lhs: usize) -> usize
pub const fn arg_mod(self, lhs: usize) -> usize
Compute the operation lhs % self.
§Note
The argument order of this function is reversed from the typical align_offset
method in the standard library.
Sourcepub const fn arg_align_offset(self, lhs: usize) -> usize
pub const fn arg_align_offset(self, lhs: usize) -> usize
Compute the amount x that would have to be added to lhs so the quantity
lhs + x is a multiple of self.
§Note
The argument order of this function is reversed from the typical align_offset
method in the standard library.
Sourcepub const fn arg_checked_next_multiple_of(self, lhs: usize) -> Option<usize>
pub const fn arg_checked_next_multiple_of(self, lhs: usize) -> Option<usize>
Calculate the smallest value greater than or equal to lhs that is a multiple of
self. Return None if the operation would result in an overflow.
Trait Implementations§
Source§impl Clone for PowerOfTwo
impl Clone for PowerOfTwo
Source§fn clone(&self) -> PowerOfTwo
fn clone(&self) -> PowerOfTwo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PowerOfTwo
impl Debug for PowerOfTwo
Source§impl From<PowerOfTwo> for usize
impl From<PowerOfTwo> for usize
Source§fn from(value: PowerOfTwo) -> Self
fn from(value: PowerOfTwo) -> Self
Source§impl PartialEq for PowerOfTwo
impl PartialEq for PowerOfTwo
impl Copy for PowerOfTwo
impl StructuralPartialEq for PowerOfTwo
Auto Trait Implementations§
impl Freeze for PowerOfTwo
impl RefUnwindSafe for PowerOfTwo
impl Send for PowerOfTwo
impl Sync for PowerOfTwo
impl Unpin for PowerOfTwo
impl UnsafeUnpin for PowerOfTwo
impl UnwindSafe for PowerOfTwo
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
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>
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>
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