diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 09:02:57 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-02-18 19:17:21 -0700 |
| commit | aeaef8c0ffadab4145fd002f2edd87a6db66ebd1 (patch) | |
| tree | e4c76c76173e5e72bc1947e1886662c4c6b2ba3c /lib/std/meta | |
| parent | f0530385b57218ef323747bdb7438330a07d25cc (diff) | |
| download | zig-aeaef8c0ffadab4145fd002f2edd87a6db66ebd1.tar.gz zig-aeaef8c0ffadab4145fd002f2edd87a6db66ebd1.zip | |
update std lib and compiler sources to new for loop syntax
Diffstat (limited to 'lib/std/meta')
| -rw-r--r-- | lib/std/meta/trailer_flags.zig | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/std/meta/trailer_flags.zig b/lib/std/meta/trailer_flags.zig index e50950018d..0c43a5ff28 100644 --- a/lib/std/meta/trailer_flags.zig +++ b/lib/std/meta/trailer_flags.zig @@ -21,7 +21,7 @@ pub fn TrailerFlags(comptime Fields: type) type { pub const ActiveFields = std.enums.EnumFieldStruct(FieldEnum, bool, false); pub const FieldValues = blk: { comptime var fields: [bit_count]Type.StructField = undefined; - inline for (@typeInfo(Fields).Struct.fields) |struct_field, i| { + inline for (@typeInfo(Fields).Struct.fields, 0..) |struct_field, i| { fields[i] = Type.StructField{ .name = struct_field.name, .type = ?struct_field.type, @@ -61,7 +61,7 @@ pub fn TrailerFlags(comptime Fields: type) type { /// `fields` is a boolean struct where each active field is set to `true` pub fn init(fields: ActiveFields) Self { var self: Self = .{ .bits = 0 }; - inline for (@typeInfo(Fields).Struct.fields) |field, i| { + inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| { if (@field(fields, field.name)) self.bits |= 1 << i; } @@ -70,7 +70,7 @@ pub fn TrailerFlags(comptime Fields: type) type { /// `fields` is a struct with each field set to an optional value pub fn setMany(self: Self, p: [*]align(@alignOf(Fields)) u8, fields: FieldValues) void { - inline for (@typeInfo(Fields).Struct.fields) |field, i| { + inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| { if (@field(fields, field.name)) |value| self.set(p, @intToEnum(FieldEnum, i), value); } @@ -101,7 +101,7 @@ pub fn TrailerFlags(comptime Fields: type) type { pub fn offset(self: Self, comptime field: FieldEnum) usize { var off: usize = 0; - inline for (@typeInfo(Fields).Struct.fields) |field_info, i| { + inline for (@typeInfo(Fields).Struct.fields, 0..) |field_info, i| { const active = (self.bits & (1 << i)) != 0; if (i == @enumToInt(field)) { assert(active); @@ -119,7 +119,7 @@ pub fn TrailerFlags(comptime Fields: type) type { pub fn sizeInBytes(self: Self) usize { var off: usize = 0; - inline for (@typeInfo(Fields).Struct.fields) |field, i| { + inline for (@typeInfo(Fields).Struct.fields, 0..) |field, i| { if (@sizeOf(field.type) == 0) continue; if ((self.bits & (1 << i)) != 0) { |
