authorgravatar for frmdstryr@protonmail.comfrmdstryr <frmdstryr@protonmail.com> 2020-07-25 20:47:50-04:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-07-27 17:05:39+03:00
logfa4a9ab51fd41ccd2a43be52cb684e4aa64b50c6
tree6e75d546e5031c7fad81ecaed4f3a69580d529ce
parente7007fa7bd94b3290982b1c39933f700e4ee133f

Use writer for LinearFifo instead of deprecated outStream


1 files changed, 8 insertions(+), 2 deletions(-)

lib/std/fifo.zig+8-2
......@@ -224,6 +224,7 @@ pub fn LinearFifo(
224224 pub fn reader(self: *Self) std.io.Reader(*Self, error{}, readFn) {
225225 return .{ .context = self };
226226 }
227
227228 /// Deprecated: `use reader`
228229 pub fn inStream(self: *Self) std.io.InStream(*Self, error{}, readFn) {
229230 return .{ .context = self };
......@@ -315,6 +316,11 @@ pub fn LinearFifo(
315316 return bytes.len;
316317 }
317318
319 pub fn writer(self: *Self) std.io.Writer(*Self, error{OutOfMemory}, appendWrite) {
320 return .{ .context = self };
321 }
322
323 /// Deprecated: `use writer`
318324 pub fn outStream(self: *Self) std.io.OutStream(*Self, error{OutOfMemory}, appendWrite) {
319325 return .{ .context = self };
320326 }
......@@ -426,14 +432,14 @@ test "LinearFifo(u8, .Dynamic)" {
426432 fifo.shrink(0);
427433
428434 {
429 try fifo.outStream().print("{}, {}!", .{ "Hello", "World" });
435 try fifo.writer().print("{}, {}!", .{ "Hello", "World" });
430436 var result: [30]u8 = undefined;
431437 testing.expectEqualSlices(u8, "Hello, World!", result[0..fifo.read(&result)]);
432438 testing.expectEqual(@as(usize, 0), fifo.readableLength());
433439 }
434440
435441 {
436 try fifo.outStream().writeAll("This is a test");
442 try fifo.writer().writeAll("This is a test");
437443 var result: [30]u8 = undefined;
438444 testing.expectEqualSlices(u8, "This", (try fifo.reader().readUntilDelimiterOrEof(&result, ' ')).?);
439445 testing.expectEqualSlices(u8, "is", (try fifo.reader().readUntilDelimiterOrEof(&result, ' ')).?);