authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-16 18:11:22 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-16 18:11:22 -07:00
log56919ce43dcc3ecee22eb7d51e90dcef0ce7f4bb
tree4e0e903296558f691407113d70a1f4b4006f1185
parentaaef4127e180916d1466e6598b616818a751a14c

allow printing any struct value that has a toString method


1 files changed, 4 insertions(+), 0 deletions(-)

src/lib.zig+4
......@@ -88,6 +88,10 @@ fn do(alloc: *std.mem.Allocator, writer: anytype, comptime value: astgen.Value,
8888 try writer.print("{d}", .{x});
8989 return;
9090 }
91 if (comptime std.meta.trait.hasFn("toString")(TO)) {
92 try writer.writeAll(try x.toString(alloc));
93 return;
94 }
9195 @compileError("pek: print: unsupported type: " ++ @typeName(TO));
9296 },
9397 .block => |v| {