commit eb67fab2d9e8540b9052e4b0d3cd0149da9d9962 (tree)
parent ce1a590fc9f57cde58c973d27461209ea2c34d37
Author: Igor Anić <igor.anic@gmail.com>
Date: Thu, 22 Feb 2024 12:29:21 +0100
refactor according to Ian's review
https://github.com/ziglang/zig/pull/19032#pullrequestreview-1894702793
Diffstat:
1 file changed, 16 insertions(+), 25 deletions(-)
diff --git a/lib/std/io/buffered_tee.zig b/lib/std/io/buffered_tee.zig
@@ -1,24 +1,23 @@
-//! BufferedTee provides reader interface to the consumer. Data read by consumer
-//! is also written to the output. Output is hold lookahead_size bytes behind
-//! consumer. Allowing consumer to put back some bytes to be read again. On flush
-//! all consumed bytes are flushed to the output.
-//!
-//! input -> tee -> consumer
-//! |
-//! output
-//!
-//! input - underlying unbuffered reader
-//! output - writer, receives data read by consumer
-//! consumer - uses provided reader interface
-//!
-//! If lookahead_size is zero output always has same bytes as consumer.
-//!
-
const std = @import("std");
const io = std.io;
const assert = std.debug.assert;
const testing = std.testing;
+/// BufferedTee provides reader interface to the consumer. Data read by consumer
+/// is also written to the output. Output is hold lookahead_size bytes behind
+/// consumer. Allowing consumer to put back some bytes to be read again. On flush
+/// all consumed bytes are flushed to the output.
+///
+/// input -> tee -> consumer
+/// |
+/// output
+///
+/// input - underlying unbuffered reader
+/// output - writer, receives data read by consumer
+/// consumer - uses provided reader interface
+///
+/// If lookahead_size is zero output always has same bytes as consumer.
+///
pub fn BufferedTee(
comptime buffer_size: usize, // internal buffer size in bytes
comptime lookahead_size: usize, // lookahead, number of bytes to hold output behind consumer
@@ -130,15 +129,7 @@ pub fn bufferedTee(
@TypeOf(input),
@TypeOf(output),
) {
- return BufferedTee(
- buffer_size,
- lookahead_size,
- @TypeOf(input),
- @TypeOf(output),
- ){
- .input = input,
- .output = output,
- };
+ return .{ .input = input, .output = output };
}
// Running test from std.io.BufferedReader on BufferedTee