zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 76f87cdd966f23106684bb38c127f6bd3f4e9fa3 (tree)
parent 78d4fb20c44488117cc450177d92c44a19d97c91
Author: Andrew Kelley <superjoe30@gmail.com>
Date:   Tue, 26 Jul 2016 18:13:22 -0700

std: add OutStream.write_byte

Diffstat:
Mstd/io.zig | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/std/io.zig b/std/io.zig @@ -63,6 +63,12 @@ pub struct OutStream { buffer: [buffer_size]u8, index: isize, + pub fn write_byte(os: &OutStream, b: u8) -> %void { + if (os.buffer.len == os.index) %return os.flush(); + os.buffer[os.index] = b; + os.index += 1; + } + pub fn write(os: &OutStream, bytes: []const u8) -> %isize { var src_bytes_left = bytes.len; var src_index: @typeof(bytes.len) = 0;