Skip to main content

const_align_up

Function const_align_up 

Source
pub const fn const_align_up(value: usize, align: Alignment) -> Option<usize>
Expand description

Aligns value up to align.

This is the const-compatible equivalent of Alignable::align_up.

Returns None on overflow.

ยงExamples

use kernel::{
    ptr::{
        const_align_up,
        Alignment, //
    },
    sizes::SZ_4K, //
};

assert_eq!(const_align_up(0x4f, Alignment::new::<16>()), Some(0x50));
assert_eq!(const_align_up(0x40, Alignment::new::<16>()), Some(0x40));
assert_eq!(const_align_up(1, Alignment::new::<SZ_4K>()), Some(SZ_4K));