diff options
author | 2022-02-11 19:01:00 -0800 | |
---|---|---|
committer | 2022-02-11 19:01:00 -0800 | |
commit | d67c95d8ebb366d14976ce74e9448a23c3d6886a (patch) | |
tree | cc43f1bfb7d26a5e9c55a7090e470dc7e210dc18 /src/string_builder.zig | |
parent | bfd7f3398cbbdce3da97158835fd311af3f73f3a (diff) | |
download | bun-d67c95d8ebb366d14976ce74e9448a23c3d6886a.tar.gz bun-d67c95d8ebb366d14976ce74e9448a23c3d6886a.tar.zst bun-d67c95d8ebb366d14976ce74e9448a23c3d6886a.zip |
[bun install] Implement bunfig.toml config
Diffstat (limited to 'src/string_builder.zig')
-rw-r--r-- | src/string_builder.zig | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/string_builder.zig b/src/string_builder.zig index 577fa1548..610ddd00f 100644 --- a/src/string_builder.zig +++ b/src/string_builder.zig @@ -30,3 +30,14 @@ pub fn append(this: *StringBuilder, slice: string) string { assert(this.len <= this.cap); return result; } + +const std = @import("std"); +pub fn fmt(this: *StringBuilder, comptime str: string, args: anytype) string { + assert(this.len <= this.cap); // didn't count everything + assert(this.ptr != null); // must call allocate first + + var buf = this.ptr.?[this.len..this.cap]; + const out = std.fmt.bufPrint(buf, str, args) catch unreachable; + this.len += out.len; + return out; +} |