authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-13 23:06:32 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-13 23:06:32 -07:00
log4ee83638fba28b550486a34e5570cb450375538c
tree4c864cc50c816c2c305c6cdd513c8d8d3cec65e2
parentdfe3e182e320f2d6e73a6f4f77ae6517bf755450

add formatting support for numbers


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

src/lib.zig+5
......@@ -58,6 +58,7 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype
5858 .replacement => |v| {
5959 const x = if (comptime std.mem.eql(u8, v[0], "this")) search(v[1..], data) else search(v, ctx);
6060 const TO = @TypeOf(x);
61 const TI = @typeInfo(TO);
6162
6263 if (comptime std.meta.trait.isZigString(TO)) {
6364 const s: []const u8 = x;
......@@ -70,6 +71,10 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype
7071 }
7172 return;
7273 }
74 if (TI == .Int or TI == .Float or TI == .ComptimeInt or TI == .ComptimeFloat) {
75 try writer.print("{d}", .{x});
76 return;
77 }
7378 @compileError("pek: print: unsupported type: " ++ @typeName(TO));
7479 },
7580 .block => |v| {