From 6e1199afa924c92e7236ad47c3c736be1bbde8c1 Mon Sep 17 00:00:00 2001 From: torque Date: Mon, 15 Jan 2024 22:40:26 -0800 Subject: [PATCH] meta: fix redundant qualifiers and improve tuple field generation --- source/meta.zig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/meta.zig b/source/meta.zig index a60d34b..ea3afa6 100644 --- a/source/meta.zig +++ b/source/meta.zig @@ -210,7 +210,7 @@ pub fn MutatingZSplitter(comptime T: type) type { pub fn copyStruct(comptime T: type, source: T, field_overrides: anytype) T { 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); }; @@ -254,9 +254,8 @@ pub const TupleBuilder = struct { comptime { var fields: [self.types.len]StructField = undefined; for (self.types, 0..) |Type, idx| { - var num_buf: [128]u8 = undefined; fields[idx] = .{ - .name = std.fmt.bufPrint(&num_buf, "{d}", .{idx}) catch @compileError("failed to write field"), + .name = std.fmt.comptimePrint("{d}", .{idx}), .type = Type, .default_value = null, // TODO: is this the right thing to do?