authorgravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-11-29 19:31:09-07:00
committergravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-11-29 19:31:09-07:00
log88a7f203f9de9a78f908dc63082173e10f9bf30e
tree660efc35e6247836c6668f1b58f8d59aae29824c
parent418b0967fc703dbad484b58bc09390e101219581

add Buffer.appendFormat()


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

std/buffer.zig+6
......@@ -4,6 +4,8 @@ const Allocator = mem.Allocator;
44const assert = debug.assert;
55const ArrayList = @import("array_list.zig").ArrayList;
66
7const fmt = @import("fmt/index.zig");
8
79/// A buffer that allocates memory and maintains a null byte at the end.
810pub const Buffer = struct {
911 list: ArrayList(u8),
......@@ -96,6 +98,10 @@ pub const Buffer = struct {
9698 mem.copy(u8, self.list.toSlice()[old_len..], m);
9799 }
98100
101 pub fn appendFormat(self: &Buffer, comptime format: []const u8, args: ...) -> %void {
102 return fmt.format(self, append, format, args);
103 }
104
99105 pub fn appendByte(self: &Buffer, byte: u8) -> %void {
100106 return self.appendByteNTimes(byte, 1);
101107 }