zig
zig copied to clipboard
std.meta: Add `LittleEndianLayout(T)` and `Stage1Layout(T)`
These are small helpers that re-order the fields of a packed struct to provide either:
-
Stage1Layout(T)- Layout compatibility with stage1, a temporary helper until users can re-define their packed structs appropriately
-
LittleEndianLayout(T)- Guaranteed in-memory layout, including for types that are currently unsupported in extern struct (e.g.
u1,u24) - Supports bit-fields (fields smaller than
u8), as long as they do not cross a byte boundary
- Guaranteed in-memory layout, including for types that are currently unsupported in extern struct (e.g.
These might be controversial, but I wanted to open the PR just in case they are helpful (especially to ease the stage1 -> stage2 transition for users)