authorgravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-04-02 20:55:59+11:00
committergravatar for quae@daurnimator.comdaurnimator <quae@daurnimator.com> 2020-04-02 21:07:44+11:00
log2a031c8825832fa70299c3fb772d8230de723c22
treeccccec431888db5b65b0bbcb41cf43f795d4a905
parentf6d384450fd7a9c6da236928ef84629bfbfbb781
signaturelock-open Commit is signed but in an unrecognized format.

std: LinearFifo matches ArrayList in always having outStream method


1 files changed, 9 insertions(+), 17 deletions(-)

lib/std/fifo.zig+9-17
...@@ -291,24 +291,16 @@ pub fn LinearFifo(...@@ -291,24 +291,16 @@ pub fn LinearFifo(
291 return self.writeAssumeCapacity(src);291 return self.writeAssumeCapacity(src);
292 }292 }
293293
294 pub usingnamespace if (T == u8)294 /// Same as `write` except it returns the number of bytes written, which is always the same
295 struct {295 /// as `bytes.len`. The purpose of this function existing is to match `std.io.OutStream` API.
296 const OutStream = std.io.OutStream(*Self, Error, appendWrite);296 fn appendWrite(self: *Self, bytes: []const u8) error{OutOfMemory}!usize {
297 const Error = error{OutOfMemory};297 try self.write(bytes);
298298 return bytes.len;
299 /// Same as `write` except it returns the number of bytes written, which is always the same299 }
300 /// as `bytes.len`. The purpose of this function existing is to match `std.io.OutStream` API.
301 pub fn appendWrite(fifo: *Self, bytes: []const u8) Error!usize {
302 try fifo.write(bytes);
303 return bytes.len;
304 }
305300
306 pub fn outStream(self: *Self) OutStream {301 pub fn outStream(self: *Self) std.io.OutStream(*Self, error{OutOfMemory}, appendWrite) {
307 return .{ .context = self };302 return .{ .context = self };
308 }303 }
309 }
310 else
311 struct {};
312304
313 /// Make `count` items available before the current read location305 /// Make `count` items available before the current read location
314 fn rewind(self: *Self, count: usize) void {306 fn rewind(self: *Self, count: usize) void {