From 88a7f203f9de9a78f908dc63082173e10f9bf30e Mon Sep 17 00:00:00 2001 From: Josh Wolfe Date: Wed, 29 Nov 2017 19:31:09 -0700 Subject: add Buffer.appendFormat() --- std/buffer.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'std/buffer.zig') diff --git a/std/buffer.zig b/std/buffer.zig index a1aa8faf9d..96abaeb762 100644 --- a/std/buffer.zig +++ b/std/buffer.zig @@ -4,6 +4,8 @@ const Allocator = mem.Allocator; const assert = debug.assert; const ArrayList = @import("array_list.zig").ArrayList; +const fmt = @import("fmt/index.zig"); + /// A buffer that allocates memory and maintains a null byte at the end. pub const Buffer = struct { list: ArrayList(u8), @@ -96,6 +98,10 @@ pub const Buffer = struct { mem.copy(u8, self.list.toSlice()[old_len..], m); } + pub fn appendFormat(self: &Buffer, comptime format: []const u8, args: ...) -> %void { + return fmt.format(self, append, format, args); + } + pub fn appendByte(self: &Buffer, byte: u8) -> %void { return self.appendByteNTimes(byte, 1); } -- cgit v1.2.3