authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-10 01:43:07 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-10 01:43:07 -07:00
log02301520811d7796de6e4f87961a44a6f458f702
treea7c673a8ebeaa47ecbb35be8fcfbee2d64c48909
parent2ada45d2e6c295a556cd8092f860630f07caf0d1
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

StructOfArrays: preserve field attributes


1 files changed, 7 insertions(+), 1 deletions(-)

src/StructOfArrays.zig+7-1
......@@ -8,12 +8,18 @@ pub fn StructOfArrays(len: usize, T: type) type {
88 const fields = info.fields;
99 var names: [fields.len][]const u8 = undefined;
1010 var types: [fields.len]type = undefined;
11 var attrs: [fields.len]std.builtin.Type.StructField.Attributes = undefined;
1112 for (fields, 0..) |item, i| {
1213 names[i] = item.name;
1314 types[i] = [len]item.type;
15 attrs[i] = .{
16 .@"comptime" = item.is_comptime,
17 .@"align" = item.alignment,
18 .default_value_ptr = item.default_value_ptr,
19 };
1420 }
1521 if (info.is_tuple) return @Tuple(&types);
16 return @Struct(.auto, null, &names, &types, &@splat(.{}));
22 return @Struct(.auto, null, &names, &types, &attrs);
1723}
1824
1925test {