Slap in workaround for Fifo

This commit is contained in:
Benjamin Feng 2020-03-06 16:52:46 -06:00
parent 6a53fe7c93
commit 786216ca5a

View File

@ -294,7 +294,19 @@ pub fn LinearFifo(
pub usingnamespace if (T == u8)
struct {
pub fn print(self: *Self, comptime format: []const u8, args: var) !void {
return std.fmt.format(self, error{OutOfMemory}, Self.write, format, args);
// TODO: maybe expose this stream as a method?
const FifoStream = struct {
const OutStream = std.io.OutStream(*Self, Error, write);
const Error = error{OutOfMemory};
fn write(fifo: *Self, bytes: []const u8) Error!usize {
try fifo.write(bytes);
return bytes.len;
}
};
var out_stream = FifoStream.OutStream{ .context = self };
try out_stream.print(format, args);
}
}
else