authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-12-13 22:27:33+11:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-01 15:48:48-07:00
log4387e50d4fa058ebc064ec8bfae07ef78774a2f4
tree529c41d1b15362a534dc002295ca0d6fcd5b6b69
parent9c97a07f18413fb0a535bc89ea9aecd1656cda6a

std: use FieldEnum from TrailerFlags


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

lib/std/meta/trailer_flags.zig+1-14
......@@ -21,20 +21,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
2121 pub const Int = meta.Int(.unsigned, bit_count);
2222 pub const bit_count = @typeInfo(Fields).Struct.fields.len;
2323
24 pub const FieldEnum = blk: {
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 };
24 pub const FieldEnum = std.meta.FieldEnum(Fields);
3825
3926 pub const InitStruct = blk: {
4027 comptime var fields: [bit_count]TypeInfo.StructField = undefined;