Trait IntAlignment

Source
pub trait IntAlignment: Sized {
    // Required methods
    fn align_down<T: Into<Self>>(self, alignment: T) -> Option<Self>;
    fn align_up<T: Into<Self>>(self, alignment: T) -> Option<Self>;
}

Required Methods§

Source

fn align_down<T: Into<Self>>(self, alignment: T) -> Option<Self>

Align self down to the closest value less or equal to self that is aligned to alignment. Returns None if and only if there is no such value. alignment must be a power of two.

Source

fn align_up<T: Into<Self>>(self, alignment: T) -> Option<Self>

Align self up to the closest value greater or equal to self that is aligned to alignment. Returns None if and only if there is no such value. alignment must be a power of two.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl IntAlignment for u8

Source§

fn align_down<T: Into<Self>>(self, alignment: T) -> Option<Self>

Source§

fn align_up<T: Into<Self>>(self, alignment: T) -> Option<Self>

Source§

impl IntAlignment for u16

Source§

fn align_down<T: Into<Self>>(self, alignment: T) -> Option<Self>

Source§

fn align_up<T: Into<Self>>(self, alignment: T) -> Option<Self>

Source§

impl IntAlignment for u32

Source§

fn align_down<T: Into<Self>>(self, alignment: T) -> Option<Self>

Source§

fn align_up<T: Into<Self>>(self, alignment: T) -> Option<Self>

Source§

impl IntAlignment for u64

Source§

fn align_down<T: Into<Self>>(self, alignment: T) -> Option<Self>

Source§

fn align_up<T: Into<Self>>(self, alignment: T) -> Option<Self>

Source§

impl IntAlignment for usize

Source§

fn align_down<T: Into<Self>>(self, alignment: T) -> Option<Self>

Source§

fn align_up<T: Into<Self>>(self, alignment: T) -> Option<Self>

Implementors§