Lines Matching defs:of

14 /// Type representing an alignment, which is always a power of two.
26 /// An alignment is always a power of two.
32 /// Validates that `ALIGN` is a power of two at build-time, and returns an [`Alignment`] of the
35 /// A build error is triggered if `ALIGN` is not a power of two.
50 "Provided alignment is not a power of two."
54 // INVARIANT: `align` is a power of two.
55 // SAFETY: `align` is a power of two, and thus non-zero.
59 /// Validates that `align` is a power of two at runtime, and returns an
60 /// [`Alignment`] of the same value.
62 /// Returns [`None`] if `align` is not a power of two.
77 // INVARIANT: `align` is a power of two.
78 // SAFETY: `align` is a power of two, and thus non-zero.
85 /// Returns the alignment of `T`.
89 pub const fn of<T>() -> Self {
91 // This cannot panic since alignments are always powers of two.
99 /// It is guaranteed to be a power of two.
115 /// It is guaranteed to be a power of two.
126 // Allow the compiler to know that the value is indeed a power of two. This can help
129 // SAFETY: Per the invariants, `self.0` is always a power of two so this block will
136 /// Returns the base-2 logarithm of the alignment.
143 /// assert_eq!(Alignment::of::<u8>().log2(), 0);
164 // No underflow can occur as the alignment is guaranteed to be a power of two, and thus is
209 // The operands of `&` need to be of the same type so convert the alignment to
237 /// This is a generalization of [`size_of`] that works for dynamically sized types.
239 /// Get the size of an object of this type in bytes, with the metadata of the given pointer.