pub struct Align { /* private fields */ }Expand description
This type is basically a copy of the Align type in the Rust compiler.
See Align.
Implementations§
source§impl Align
impl Align
sourcepub fn from_bytes(align: impl Into<Int>) -> Option<Align>
pub fn from_bytes(align: impl Into<Int>) -> Option<Align>
Constructs Align with align many bytes.
Returns None if align is not a power of two.
sourcepub const fn from_bytes_const(align: u64) -> Option<Align>
pub const fn from_bytes_const(align: u64) -> Option<Align>
Variation of from_bytes for const contexts.
sourcepub fn from_bits(align: impl Into<Int>) -> Option<Align>
pub fn from_bits(align: impl Into<Int>) -> Option<Align>
Constructs Align with align many bits.
Returns None if align is not divisible by 8, or if align/8 is no power of two.
sourcepub const fn from_bits_const(align: u64) -> Option<Align>
pub const fn from_bits_const(align: u64) -> Option<Align>
Variation of from_bits for const contexts.
sourcepub fn max_for_offset(offset: Size) -> Option<Align>
pub fn max_for_offset(offset: Size) -> Option<Align>
Computes the best alignment possible for the given offset
(the largest power of two that the offset is a multiple of).
For an offset of 0 it returns None.
sourcepub fn restrict_for_offset(self, offset: Size) -> Align
pub fn restrict_for_offset(self, offset: Size) -> Align
Lower the alignment if necessary, such that the given offset is aligned to it (the offset is a multiple of the alignment).
sourcepub fn is_aligned(self, addr: Int) -> bool
pub fn is_aligned(self, addr: Int) -> bool
Check if the given address is sufficiently aligned.
Trait Implementations§
source§impl Ord for Align
impl Ord for Align
source§impl PartialEq for Align
impl PartialEq for Align
source§impl PartialOrd for Align
impl PartialOrd for Align
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Copy for Align
impl Eq for Align
impl StructuralPartialEq for Align
Auto Trait Implementations§
impl Freeze for Align
impl RefUnwindSafe for Align
impl !Send for Align
impl !Sync for Align
impl Unpin for Align
impl UnwindSafe for Align
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