Commit 4387e50d4f

daurnimator <quae@daurnimator.com>
2020-12-13 12:27:33
std: use FieldEnum from TrailerFlags
1 parent 9c97a07
Changed files (1)
lib
lib/std/meta/trailer_flags.zig
@@ -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;