feature. See also
. The project being documented here (as the example) is the Zig library itself.
Builder.typeExtraDataTrail
fn typeExtraDataTrail(
self: *const Builder,
comptime T: type,
index: Type.Item.ExtraIndex,
) struct
File
Code
fn typeExtraDataTrail(
self: *const Builder,
comptime T: type,
index: Type.Item.ExtraIndex,
) struct { data: T, trail: TypeExtraDataTrail } {
var result: T = undefined;
const info = @typeInfo(T).@"struct";
inline for (
info.field_names,
info.field_types,
self.type_extra.items[index..][0..info.field_names.len],
) |field_name, field_type, value|
@field(result, field_name) = switch (field_type) {
u32 => value,
String, Type => @fromBackingInt(@intCast(value)),
else => @compileError("bad field type: " ++ @typeName(field_type)),
};
return .{
.data = result,
.trail = .{ .index = index + @as(Type.Item.ExtraIndex, @intCast(info.field_names.len)) },
};
}