pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type 33
34
35
36
37
38pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type {
@setEvalBranchQuota(@typeInfo(E).@"enum".field_names.len + eval_branch_quota_cushion);
const default_ptr: ?*const anyopaque = if (field_default) |d| @ptrCast(&d) else null;
const field_names = @typeInfo(E).@"enum".field_names;
return @Struct(.auto, null, field_names, &@splat(Data), &@splat(.{ .default_value_ptr = default_ptr }));
}
Returns a struct with a field matching each unique named enum element. If the enum is extern and has multiple names for the same value, only the first name is used. Each field is of type Data and has the provided default, which may be undefined.