| ... | @@ -4,6 +4,8 @@ const Allocator = mem.Allocator; | ... | @@ -4,6 +4,8 @@ const Allocator = mem.Allocator; |
| 4 | const assert = debug.assert; | 4 | const assert = debug.assert; |
| 5 | const ArrayList = @import("array_list.zig").ArrayList; | 5 | const ArrayList = @import("array_list.zig").ArrayList; |
| 6 | | 6 | |
| | 7 | const fmt = @import("fmt/index.zig"); |
| | 8 | |
| 7 | /// A buffer that allocates memory and maintains a null byte at the end. | 9 | /// A buffer that allocates memory and maintains a null byte at the end. |
| 8 | pub const Buffer = struct { | 10 | pub const Buffer = struct { |
| 9 | list: ArrayList(u8), | 11 | list: ArrayList(u8), |
| ... | @@ -96,6 +98,10 @@ pub const Buffer = struct { | ... | @@ -96,6 +98,10 @@ pub const Buffer = struct { |
| 96 | mem.copy(u8, self.list.toSlice()[old_len..], m); | 98 | mem.copy(u8, self.list.toSlice()[old_len..], m); |
| 97 | } | 99 | } |
| 98 | | 100 | |
| | 101 | pub fn appendFormat(self: &Buffer, comptime format: []const u8, args: ...) -> %void { |
| | 102 | return fmt.format(self, append, format, args); |
| | 103 | } |
| | 104 | |
| 99 | pub fn appendByte(self: &Buffer, byte: u8) -> %void { | 105 | pub fn appendByte(self: &Buffer, byte: u8) -> %void { |
| 100 | return self.appendByteNTimes(byte, 1); | 106 | return self.appendByteNTimes(byte, 1); |
| 101 | } | 107 | } |