| ... | @@ -21,20 +21,7 @@ pub fn TrailerFlags(comptime Fields: type) type { | ... | @@ -21,20 +21,7 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 21 | pub const Int = meta.Int(.unsigned, bit_count); | 21 | pub const Int = meta.Int(.unsigned, bit_count); |
| 22 | pub const bit_count = @typeInfo(Fields).Struct.fields.len; | 22 | pub const bit_count = @typeInfo(Fields).Struct.fields.len; |
| 23 | | 23 | |
| 24 | pub const FieldEnum = blk: { | 24 | pub const FieldEnum = std.meta.FieldEnum(Fields); |
| 25 | comptime var fields: [bit_count]TypeInfo.EnumField = undefined; | | |
| 26 | inline for (@typeInfo(Fields).Struct.fields) |struct_field, i| | | |
| 27 | fields[i] = .{ .name = struct_field.name, .value = i }; | | |
| 28 | break :blk @Type(.{ | | |
| 29 | .Enum = .{ | | |
| 30 | .layout = .Auto, | | |
| 31 | .tag_type = std.math.IntFittingRange(0, bit_count - 1), | | |
| 32 | .fields = &fields, | | |
| 33 | .decls = &[_]TypeInfo.Declaration{}, | | |
| 34 | .is_exhaustive = true, | | |
| 35 | }, | | |
| 36 | }); | | |
| 37 | }; | | |
| 38 | | 25 | |
| 39 | pub const InitStruct = blk: { | 26 | pub const InitStruct = blk: { |
| 40 | comptime var fields: [bit_count]TypeInfo.StructField = undefined; | 27 | comptime var fields: [bit_count]TypeInfo.StructField = undefined; |