mirror of
https://github.com/ziglang/zig.git
synced 2026-01-21 14:55:25 +00:00
std: use FieldEnum from TrailerFlags
This commit is contained in:
parent
9c97a07f18
commit
4387e50d4f
@ -21,20 +21,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
|
||||
pub const Int = meta.Int(.unsigned, bit_count);
|
||||
pub const bit_count = @typeInfo(Fields).Struct.fields.len;
|
||||
|
||||
pub const FieldEnum = blk: {
|
||||
comptime var fields: [bit_count]TypeInfo.EnumField = undefined;
|
||||
inline for (@typeInfo(Fields).Struct.fields) |struct_field, i|
|
||||
fields[i] = .{ .name = struct_field.name, .value = i };
|
||||
break :blk @Type(.{
|
||||
.Enum = .{
|
||||
.layout = .Auto,
|
||||
.tag_type = std.math.IntFittingRange(0, bit_count - 1),
|
||||
.fields = &fields,
|
||||
.decls = &[_]TypeInfo.Declaration{},
|
||||
.is_exhaustive = true,
|
||||
},
|
||||
});
|
||||
};
|
||||
pub const FieldEnum = std.meta.FieldEnum(Fields);
|
||||
|
||||
pub const InitStruct = blk: {
|
||||
comptime var fields: [bit_count]TypeInfo.StructField = undefined;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user