diff options
Diffstat (limited to 'src/util.zig')
| -rw-r--r-- | src/util.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/util.zig b/src/util.zig new file mode 100644 index 0000000..e168326 --- /dev/null +++ b/src/util.zig @@ -0,0 +1,21 @@ +const std = @import("std"); + +const state = struct { + var buf: [256]u8 = undefined; +}; +var fba = std.heap.FixedBufferAllocator.init(state.buf[0..]); + +pub fn tmpZ(str: []const u8) ![:0]const u8 { + fba.reset(); + return try std.fmt.allocPrintZ(fba.allocator(), "{s}", .{str}); +} + +pub fn tmpFmtZ(comptime fmt: []const u8, args: anytype) ![:0]const u8 { + fba.reset(); + return try std.fmt.allocPrintZ(fba.allocator(), fmt, args); +} + +pub fn tmpJoinZ(separator: []const u8, slices: []const []const u8) ![:0]const u8 { + fba.reset(); + return try std.mem.joinZ(fba.allocator(), separator, slices); +} |
