@@ -129,7 +129,7 @@ fn serializeRecursive(stream: anytype, comptime T: type, value: T) @TypeOf(strea
129
129
// hash all names in the right order
130
130
const names = getSortedErrorNames (T );
131
131
132
- const index = for (names ) | name , i | {
132
+ const index = for (names , 0 .. ) | name , i | {
133
133
if (std .mem .eql (u8 , name , @errorName (value )))
134
134
break @intCast (u16 , i );
135
135
} else unreachable ;
@@ -287,7 +287,7 @@ fn recursiveDeserialize(stream: anytype, comptime T: type, allocator: ?std.mem.A
287
287
const names = comptime getSortedErrorNames (T );
288
288
const index = try stream .readIntLittle (u16 );
289
289
290
- inline for (names ) | name , i | {
290
+ inline for (names , 0 .. ) | name , i | {
291
291
if (i == index ) {
292
292
target .* = @field (T , name );
293
293
return ;
@@ -481,7 +481,7 @@ fn getSortedErrorNames(comptime T: type) []const []const u8 {
481
481
const error_set = @typeInfo (T ).ErrorSet orelse @compileError ("Cannot serialize anyerror" );
482
482
483
483
var sorted_names : [error_set .len ][]const u8 = undefined ;
484
- for (error_set ) | err , i | {
484
+ for (error_set , 0 .. ) | err , i | {
485
485
sorted_names [i ] = err .name ;
486
486
}
487
487
@@ -500,7 +500,7 @@ fn getSortedEnumNames(comptime T: type) []const []const u8 {
500
500
const type_info = @typeInfo (T ).Enum ;
501
501
502
502
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 | {
504
504
sorted_names [i ] = err .name ;
505
505
}
506
506
0 commit comments