Lines Matching refs:alignment
19 /// Type representing an alignment, which is always a power of two.
21 /// It is used to validate that a given value is a valid alignment, and to perform masking and
22 /// alignment operations.
31 /// An alignment is always a power of two.
54 "Provided alignment is not a power of two."
88 /// Returns the alignment of `T`.
99 /// Returns this alignment as a [`usize`].
115 /// Returns this alignment as a [`NonZero`].
138 /// Returns the base-2 logarithm of the alignment.
153 /// Returns the mask for this alignment.
166 // No underflow can occur as the alignment is guaranteed to be a power of two, and thus is
174 Some(alignment) => alignment,
181 /// Aligns `self` down to `alignment`.
192 fn align_down(self, alignment: Alignment) -> Self;
194 /// Aligns `self` up to `alignment`, returning `None` if aligning would result in an overflow.
208 fn align_up(self, alignment: Alignment) -> Option<Self>;
217 fn align_down(self, alignment: Alignment) -> Self {
218 // The operands of `&` need to be of the same type so convert the alignment to
220 ::core::num::NonZero::<Self>::try_from(alignment.as_nonzero())
222 // An alignment larger than `Self` always aligns down to `0`.
227 fn align_up(self, alignment: Alignment) -> Option<Self> {
228 let aligned_down = self.align_down(alignment);
232 Self::try_from(alignment.as_usize())
251 /// Minimum alignment of this type known at compile-time.