Trait align_address::Align

source ·
pub trait Align<A = Self>: Copy + PartialEq {
    // Required methods
    fn align_down(self, align: A) -> Self;
    fn align_up(self, align: A) -> Self;

    // Provided method
    fn is_aligned(self, align: A) -> bool { ... }
}
Expand description

An adress that can be aligned.

Required Methods§

source

fn align_down(self, align: A) -> Self

Align address downwards.

Returns the greatest x with alignment align so that x <= addr.

Panics if the alignment is not a power of two.

source

fn align_up(self, align: A) -> Self

Align address upwards.

Returns the smallest x with alignment align so that x >= addr.

Panics if the alignment is not a power of two or if an overflow occurs.

Provided Methods§

source

fn is_aligned(self, align: A) -> bool

Checks whether the address has the demanded alignment.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Align for u8

source§

fn align_down(self, align: Self) -> Self

source§

fn align_up(self, align: Self) -> Self

source§

impl Align for u16

source§

fn align_down(self, align: Self) -> Self

source§

fn align_up(self, align: Self) -> Self

source§

impl Align for u32

source§

fn align_down(self, align: Self) -> Self

source§

fn align_up(self, align: Self) -> Self

source§

impl Align for u64

source§

fn align_down(self, align: Self) -> Self

source§

fn align_up(self, align: Self) -> Self

source§

impl Align for u128

source§

fn align_down(self, align: Self) -> Self

source§

fn align_up(self, align: Self) -> Self

source§

impl Align for usize

source§

fn align_down(self, align: Self) -> Self

source§

fn align_up(self, align: Self) -> Self

Implementors§