Lines Matching full:align
34 /// Validates that `ALIGN` is a power of two at build-time, and returns an [`Alignment`] of the
37 /// A build error is triggered if `ALIGN` is not a power of two.
48 pub const fn new<const ALIGN: usize>() -> Self { in new()
50 ALIGN.is_power_of_two(), in new()
54 // INVARIANT: `align` is a power of two. in new()
55 // SAFETY: `align` is a power of two, and thus non-zero. in new()
56 Self(unsafe { NonZero::new_unchecked(ALIGN) }) in new()
59 /// Validates that `align` is a power of two at runtime, and returns an
62 /// Returns [`None`] if `align` is not a power of two.
75 pub const fn new_checked(align: usize) -> Option<Self> { in new_checked()
76 if align.is_power_of_two() { in new_checked()
77 // INVARIANT: `align` is a power of two. in new_checked()
78 // SAFETY: `align` is a power of two, and thus non-zero. in new_checked()
79 Some(Self(unsafe { NonZero::new_unchecked(align) })) in new_checked()
211 .map(|align| self & !(align.get() - 1))
224 .and_then(|align| aligned_down.checked_add(align))
256 /// Aligns `value` up to `align`.
278 pub const fn const_align_up(value: usize, align: Alignment) -> Option<usize> { in const_align_up()
279 match value.checked_add(align.as_usize() - 1) { in const_align_up()
280 Some(v) => Some(v & align.mask()), in const_align_up()