[][src]Function maligned::align_first

#[must_use]pub fn align_first<T, A: Alignment>(t_capacity: usize) -> Vec<T>

Aligns the first element in a Vec<T> to A. If the alignment of A is less than the alignment of T then a Vec<T> with capacity t_capacity is returned. This method is safe because structs are always aligned to a power of two so aligning the first item in a Vec<T> to a higher alignment will always be aligned correctly.

This method is useful for getting byte arrays that need to be copied so that an efficient memory copy can be used instead of a byte by byte copy. It is also useful when working on some devices that can do hardware copies but require 128, 256, or higher bit alignments to be efficient.