Skip to main content

assert_segment_field_alignment

Function assert_segment_field_alignment 

Source
pub const fn assert_segment_field_alignment<T: SegmentMap + FieldMap>(
    header_offset: usize,
)
Expand description

Compile-time assertion that a type’s SegmentMap and FieldMap are isomorphic: same count, same names, same offsets, same sizes.

Generated macros should produce both from a single source; this catches any accidental divergence.

Usage:

const _: () = assert_segment_field_alignment::<MyLayout>(HEADER_LEN);

header_offset is subtracted from FieldInfo.offset before comparing with StaticSegment.offset, since FieldInfo offsets are absolute (including the Hopper header) while StaticSegment offsets are relative to the body start.