pub struct AlignmentValue(/* private fields */);
Expand description
Helper type for alignment calculations
Implementations§
Source§impl AlignmentValue
impl AlignmentValue
pub const fn new(val: u64) -> Self
Sourcepub const fn from_next_power_of_two_size(size: SizeValue) -> Self
pub const fn from_next_power_of_two_size(size: SizeValue) -> Self
Returns an alignment that is the smallest power of two greater than the passed in size
pub const fn get(&self) -> u64
Sourcepub const fn max<const N: usize>(input: [AlignmentValue; N]) -> AlignmentValue
pub const fn max<const N: usize>(input: [AlignmentValue; N]) -> AlignmentValue
Returns the max alignment from an array of alignments
Sourcepub const fn is_aligned(&self, n: u64) -> bool
pub const fn is_aligned(&self, n: u64) -> bool
Returns true if n
is a multiple of this alignment
Sourcepub const fn padding_needed_for(&self, n: u64) -> u64
pub const fn padding_needed_for(&self, n: u64) -> u64
Returns the amount of padding needed so that n + padding
will be a multiple of this alignment
Sourcepub const fn round_up(&self, n: u64) -> u64
pub const fn round_up(&self, n: u64) -> u64
Will round up the given n
so that the returned value will be a multiple of this alignment
Sourcepub const fn round_up_size(&self, n: SizeValue) -> SizeValue
pub const fn round_up_size(&self, n: SizeValue) -> SizeValue
Will round up the given n
so that the returned value will be a multiple of this alignment
Trait Implementations§
Source§impl Clone for AlignmentValue
impl Clone for AlignmentValue
Source§fn clone(&self) -> AlignmentValue
fn clone(&self) -> AlignmentValue
Returns a copy 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 AlignmentValue
impl Debug for AlignmentValue
Source§impl PartialEq for AlignmentValue
impl PartialEq for AlignmentValue
impl Copy for AlignmentValue
impl Eq for AlignmentValue
impl StructuralPartialEq for AlignmentValue
Auto Trait Implementations§
impl Freeze for AlignmentValue
impl RefUnwindSafe for AlignmentValue
impl Send for AlignmentValue
impl Sync for AlignmentValue
impl Unpin for AlignmentValue
impl UnwindSafe for AlignmentValue
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)