From 76f87cdd966f23106684bb38c127f6bd3f4e9fa3 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 26 Jul 2016 18:13:22 -0700 Subject: [PATCH] std: add OutStream.write_byte --- std/io.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/std/io.zig b/std/io.zig index d64514ac39..8d40bd95d7 100644 --- 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;