authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-21 21:14:59 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-10-21 21:14:59 -07:00
log2352c1b2b2a15b3ce60914adcbc9567184efac59
tree2bd0241be806d641b0bdb105db4e84ff78146242
parent56919ce43dcc3ecee22eb7d51e90dcef0ce7f4bb

allow replacements to also use format function


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

src/lib.zig+3
...@@ -88,6 +88,9 @@ fn do(alloc: *std.mem.Allocator, writer: anytype, comptime value: astgen.Value,...@@ -88,6 +88,9 @@ fn do(alloc: *std.mem.Allocator, writer: anytype, comptime value: astgen.Value,
88 try writer.print("{d}", .{x});88 try writer.print("{d}", .{x});
89 return;89 return;
90 }90 }
91 if (comptime std.meta.trait.hasFn("format")(TO)) {
92 return std.fmt.format(writer, "{}", .{x});
93 }
91 if (comptime std.meta.trait.hasFn("toString")(TO)) {94 if (comptime std.meta.trait.hasFn("toString")(TO)) {
92 try writer.writeAll(try x.toString(alloc));95 try writer.writeAll(try x.toString(alloc));
93 return;96 return;