Skip to main content

merge_inline_list

Function merge_inline_list 

Source
pub fn merge_inline_list<'a, T, V, B, F>(
    views: &'a [V],
    out: &mut B,
    elem_size: usize,
    align_mask: usize,
    get_list: F,
) -> usize
where B: Buffer, T: ReadAt<'a>, F: Fn(&'a V) -> ListView<'a, T>,
Expand description

Merge a List(Inline) field — packed scalar or #[repr(C)] struct arrays.

§Algorithm

Pre-allocates one contiguous aligned region for all elements from all views combined, then fills it view-by-view in reverse order so that self (the last view) lands at the lowest address and is therefore read first when iterating.

Correctness of the single-allocation approach: for any valid Pod type T, size_of::<T>() is a multiple of align_of::<T>(). Therefore N * size_of::<T>() is always aligned for T, meaning consecutive blocks of different views remain contiguous with no padding gaps between them.

§Returns

The slot of the length-prefix u32, or 0 if all views were empty.