Commit 76f87cdd96

Andrew Kelley <superjoe30@gmail.com>
2016-07-27 03:13:22
std: add OutStream.write_byte
1 parent 78d4fb2
Changed files (1)
std
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;