Skip to content

Commit 8715672

Browse files
fabioarnoldikskuh
authored andcommitted
Fix for loops
1 parent 8fc312f commit 8715672

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

s2s.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ fn serializeRecursive(stream: anytype, comptime T: type, value: T) @TypeOf(strea
129129
// hash all names in the right order
130130
const names = getSortedErrorNames(T);
131131

132-
const index = for (names) |name, i| {
132+
const index = for (names, 0..) |name, i| {
133133
if (std.mem.eql(u8, name, @errorName(value)))
134134
break @intCast(u16, i);
135135
} else unreachable;
@@ -287,7 +287,7 @@ fn recursiveDeserialize(stream: anytype, comptime T: type, allocator: ?std.mem.A
287287
const names = comptime getSortedErrorNames(T);
288288
const index = try stream.readIntLittle(u16);
289289

290-
inline for (names) |name, i| {
290+
inline for (names, 0..) |name, i| {
291291
if (i == index) {
292292
target.* = @field(T, name);
293293
return;
@@ -481,7 +481,7 @@ fn getSortedErrorNames(comptime T: type) []const []const u8 {
481481
const error_set = @typeInfo(T).ErrorSet orelse @compileError("Cannot serialize anyerror");
482482

483483
var sorted_names: [error_set.len][]const u8 = undefined;
484-
for (error_set) |err, i| {
484+
for (error_set, 0..) |err, i| {
485485
sorted_names[i] = err.name;
486486
}
487487

@@ -500,7 +500,7 @@ fn getSortedEnumNames(comptime T: type) []const []const u8 {
500500
const type_info = @typeInfo(T).Enum;
501501

502502
var sorted_names: [type_info.fields.len][]const u8 = undefined;
503-
for (type_info.fields) |err, i| {
503+
for (type_info.fields, 0..) |err, i| {
504504
sorted_names[i] = err.name;
505505
}
506506

0 commit comments

Comments
 (0)