AlignTo

Trait AlignTo 

Source
pub trait AlignTo {
    type TAlign;

    // Required methods
    fn align_to(self, align: Self::TAlign) -> Self;
    fn aligned_to(self, align: Self::TAlign) -> bool;
}
Expand description

Helper to implement generic alignment operator.

Required Associated Types§

Required Methods§

Source

fn align_to(self, align: Self::TAlign) -> Self

Aligns the given value to a multiple of the align value.

Debug asserts that align is a power of two, otherwise calculates an incorrect result.

Source

fn aligned_to(self, align: Self::TAlign) -> bool

Checks if the given value is aligned to a multiple of the align value.

Debug asserts that align is a power of two, otherwise calculates an incorrect result.

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 AlignTo for u8

Source§

type TAlign = u8

Source§

fn align_to(self, align: u8) -> u8

Source§

fn aligned_to(self, align: u8) -> bool

Source§

impl AlignTo for u16

Source§

type TAlign = u16

Source§

fn align_to(self, align: u16) -> u16

Source§

fn aligned_to(self, align: u16) -> bool

Source§

impl AlignTo for u32

Source§

type TAlign = u32

Source§

fn align_to(self, align: u32) -> u32

Source§

fn aligned_to(self, align: u32) -> bool

Source§

impl AlignTo for u64

Source§

type TAlign = u64

Source§

fn align_to(self, align: u64) -> u64

Source§

fn aligned_to(self, align: u64) -> bool

Source§

impl AlignTo for u128

Source§

type TAlign = u128

Source§

fn align_to(self, align: u128) -> u128

Source§

fn aligned_to(self, align: u128) -> bool

Source§

impl AlignTo for usize

Source§

type TAlign = usize

Source§

fn align_to(self, align: usize) -> usize

Source§

fn aligned_to(self, align: usize) -> bool

Source§

impl<T> AlignTo for *const T

Source§

type TAlign = usize

Source§

fn align_to(self, align: usize) -> *const T

Source§

fn aligned_to(self, align: usize) -> bool

Source§

impl<T> AlignTo for *mut T

Source§

type TAlign = usize

Source§

fn align_to(self, align: usize) -> *mut T

Source§

fn aligned_to(self, align: usize) -> bool

Implementors§