Expand description
Stack-resident, fixed-capacity scratch buffer.
AlignedBuf is the zero-heap complement to
super::aligned_vec::AlignedVec: it stores up to N elements inline in
the struct itself, making it a zero-cost abstraction for small hot-path
buffers whose maximum size is known at compile time.
§Design
The backing store is [MaybeUninit<T>; N]. Only the first len slots are
initialized; unwritten slots hold unspecified bytes. ScratchElement’s
Copy super-bound means there are no destructors to run, so clear is a
single field write and pop / drop never leak resources.
§Zero heap
No allocator call is ever made by AlignedBuf’s own methods. When
monomorphized the optimizer can keep small instances entirely in registers
or a stack frame.
§Copy
AlignedBuf<T, N> is Copy (every ScratchElement is). The copy
includes the len field, so the semantics are identical to copying
[T; len].
Structs§
- Aligned
Buf - A stack-resident, fixed-capacity buffer holding up to
Nelements ofT.