From 1333830fcf6b8e99bb0d9497ceaea79251e5195c Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Wed, 22 Feb 2023 23:20:14 +0100 Subject: fix for latest zig by running 'zig fmt' --- sqlite.zig | 24 ++++++++++++------------ vtab.zig | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sqlite.zig b/sqlite.zig index 1b39a04..77c30fc 100644 --- a/sqlite.zig +++ b/sqlite.zig @@ -748,7 +748,7 @@ pub const Db = struct { const sqlite_args = argv[0..fn_info.params.len]; var fn_args: ArgTuple = undefined; - inline for (fn_info.params) |arg, i| { + inline for (fn_info.params, 0..) |arg, i| { const ArgType = arg.type.?; helpers.setTypeFromValue(ArgType, &fn_args[i], sqlite_args[i].?); } @@ -1395,7 +1395,7 @@ pub fn Iterator(comptime Type: type) type { var value: Type = undefined; - inline for (@typeInfo(Type).Struct.fields) |field, _i| { + inline for (@typeInfo(Type).Struct.fields, 0..) |field, _i| { const i = @as(usize, _i); const ret = try self.readField(field.type, options, i); @@ -1721,7 +1721,7 @@ pub const DynamicStatement = struct { switch (@typeInfo(Type)) { .Struct => |StructTypeInfo| { - inline for (StructTypeInfo.fields) |struct_field, struct_field_i| { + inline for (StructTypeInfo.fields, 0..) |struct_field, struct_field_i| { const field_value = @field(values, struct_field.name); const i = sqlite3BindParameterIndex(self.stmt, struct_field.name); @@ -1735,7 +1735,7 @@ pub const DynamicStatement = struct { .Pointer => |PointerTypeInfo| { switch (PointerTypeInfo.size) { .Slice => { - for (values) |value_to_bind, index| { + for (values, 0..) |value_to_bind, index| { try self.bindField(PointerTypeInfo.child, options, "unknown", @intCast(c_int, index), value_to_bind); } }, @@ -1743,7 +1743,7 @@ pub const DynamicStatement = struct { } }, .Array => |ArrayTypeInfo| { - for (values) |value_to_bind, index| { + for (values, 0..) |value_to_bind, index| { try self.bindField(ArrayTypeInfo.child, options, "unknown", @intCast(c_int, index), value_to_bind); } }, @@ -2025,7 +2025,7 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: anytype) type })); } - inline for (StructTypeInfo.fields) |struct_field, _i| { + inline for (StructTypeInfo.fields, 0..) |struct_field, _i| { const bind_marker = query.bind_markers[_i]; if (bind_marker.typed) |typ| { const FieldTypeInfo = @typeInfo(struct_field.type); @@ -2497,7 +2497,7 @@ test "sqlite: read all users into a struct" { var rows = try stmt.all(TestUser, allocator, .{}, .{}); try testing.expectEqual(@as(usize, 3), rows.len); - for (rows) |row, i| { + for (rows, 0..) |row, i| { const exp = test_users[i]; try testing.expectEqual(exp.id, row.id); try testing.expectEqualStrings(exp.name, row.name); @@ -2828,7 +2828,7 @@ test "sqlite: bind pointer" { var stmt = try db.prepare(query); defer stmt.deinit(); - for (test_users) |test_user, i| { + for (test_users, 0..) |test_user, i| { stmt.reset(); const name = try stmt.oneAlloc([]const u8, allocator, .{}, .{&test_user.id}); @@ -2864,7 +2864,7 @@ test "sqlite: read pointers" { ); try testing.expectEqual(@as(usize, 3), rows.len); - for (rows) |row, i| { + for (rows, 0..) |row, i| { const exp = test_users[i]; try testing.expectEqual(exp.id, row.id.*); try testing.expectEqualStrings(exp.name, row.name.*); @@ -2998,7 +2998,7 @@ test "sqlite: statement iterator" { // Check the data try testing.expectEqual(expected_rows.items.len, rows.items.len); - for (rows.items) |row, j| { + for (rows.items, 0..) |row, j| { const exp_row = expected_rows.items[j]; try testing.expectEqualStrings(exp_row.name, mem.sliceTo(&row.name, 0)); try testing.expectEqual(exp_row.age, row.age); @@ -3025,7 +3025,7 @@ test "sqlite: statement iterator" { // Check the data try testing.expectEqual(expected_rows.items.len, rows.items.len); - for (rows.items) |row, j| { + for (rows.items, 0..) |row, j| { const exp_row = expected_rows.items[j]; try testing.expectEqualStrings(exp_row.name, row.name.data); try testing.expectEqual(exp_row.age, row.age); @@ -3386,7 +3386,7 @@ test "sqlite: bind custom type" { const rows = try stmt.all(Article, arena.allocator(), .{}, .{}); try testing.expectEqual(@as(usize, 20), rows.len); - for (rows) |row, i| { + for (rows, 0..) |row, i| { var exp_data: MyData = undefined; mem.set(u8, &exp_data.data, @intCast(u8, i)); diff --git a/vtab.zig b/vtab.zig index aef1b40..a7645c3 100644 --- a/vtab.zig +++ b/vtab.zig @@ -207,7 +207,7 @@ pub const BestIndexBuilder = struct { .id = .{}, }; - for (res.constraints) |*constraint, i| { + for (res.constraints, 0..) |*constraint, i| { const raw_constraint = index_info.aConstraint[i]; constraint.column = @intCast(isize, raw_constraint.iColumn); @@ -233,7 +233,7 @@ pub const BestIndexBuilder = struct { // Populate the constraint usage var constraint_usage: []c.sqlite3_index_constraint_usage = index_info.aConstraintUsage[0..self.constraints.len]; - for (self.constraints) |constraint, i| { + for (self.constraints, 0..) |constraint, i| { constraint_usage[i].argvIndex = constraint.usage.argv_index; constraint_usage[i].omit = if (constraint.usage.omit) 1 else 0; } @@ -541,7 +541,7 @@ fn parseModuleArguments(allocator: mem.Allocator, argc: c_int, argv: [*c]const [ var res = try allocator.alloc(ModuleArgument, @intCast(usize, argc)); errdefer allocator.free(res); - for (res) |*marg, i| { + for (res, 0..) |*marg, i| { // The documentation of sqlite says each string in argv is null-terminated const arg = mem.sliceTo(argv[i], 0); @@ -840,7 +840,7 @@ pub fn VirtualTable( const size = @intCast(usize, argc); var res = try allocator.alloc(FilterArg, size); - for (res) |*item, i| { + for (res, 0..) |*item, i| { item.* = .{ .value = argv[i], }; @@ -1276,7 +1276,7 @@ test "parse module arguments" { const allocator = arena.allocator(); var args = try allocator.alloc([*c]const u8, 20); - for (args) |*arg, i| { + for (args, 0..) |*arg, i| { const tmp = try fmt.allocPrintZ(allocator, "arg={d}", .{i}); arg.* = @ptrCast([*c]const u8, tmp); } @@ -1288,7 +1288,7 @@ test "parse module arguments" { ); try testing.expectEqual(@as(usize, 20), res.len); - for (res) |arg, i| { + for (res, 0..) |arg, i| { try testing.expectEqualStrings("arg", arg.kv.key); try testing.expectEqual(i, try fmt.parseInt(usize, arg.kv.value, 10)); } -- cgit v1.2.3