meta: fix redundant qualifiers and improve tuple field generation

This commit is contained in:
torque 2024-01-15 22:40:26 -08:00
parent 70c6cea591
commit 6e1199afa9
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk

View File

@ -210,7 +210,7 @@ pub fn MutatingZSplitter(comptime T: type) type {
pub fn copyStruct(comptime T: type, source: T, field_overrides: anytype) T { pub fn copyStruct(comptime T: type, source: T, field_overrides: anytype) T {
var result: T = undefined; var result: T = undefined;
comptime inline for (@typeInfo(@TypeOf(field_overrides)).Struct.fields) |field| { comptime for (@typeInfo(@TypeOf(field_overrides)).Struct.fields) |field| {
if (!@hasField(T, field.name)) @compileError("override contains bad field" ++ field); if (!@hasField(T, field.name)) @compileError("override contains bad field" ++ field);
}; };
@ -254,9 +254,8 @@ pub const TupleBuilder = struct {
comptime { comptime {
var fields: [self.types.len]StructField = undefined; var fields: [self.types.len]StructField = undefined;
for (self.types, 0..) |Type, idx| { for (self.types, 0..) |Type, idx| {
var num_buf: [128]u8 = undefined;
fields[idx] = .{ fields[idx] = .{
.name = std.fmt.bufPrint(&num_buf, "{d}", .{idx}) catch @compileError("failed to write field"), .name = std.fmt.comptimePrint("{d}", .{idx}),
.type = Type, .type = Type,
.default_value = null, .default_value = null,
// TODO: is this the right thing to do? // TODO: is this the right thing to do?