From 4ee83638fba28b550486a34e5570cb450375538c Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Fri, 13 Aug 2021 23:06:32 -0700 Subject: [PATCH] add formatting support for numbers --- src/lib.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib.zig b/src/lib.zig index 1f42cdbe87049d9298132b7ff3ad375e9dbc4522..6745d48ec33f9cc399f0674e863b11a06ebed92c 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -58,6 +58,7 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype .replacement => |v| { const x = if (comptime std.mem.eql(u8, v[0], "this")) search(v[1..], data) else search(v, ctx); const TO = @TypeOf(x); + const TI = @typeInfo(TO); if (comptime std.meta.trait.isZigString(TO)) { const s: []const u8 = x; @@ -70,6 +71,10 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype } return; } + if (TI == .Int or TI == .Float or TI == .ComptimeInt or TI == .ComptimeFloat) { + try writer.print("{d}", .{x}); + return; + } @compileError("pek: print: unsupported type: " ++ @typeName(TO)); }, .block => |v| { -- 2.54.0