| author | |
| committer | |
| log | ff047c05bdd2825e9964875c6b29fa3bf4461a79 |
| tree | ea98ddc2331a0a8cbc1112d4a175570f3be0a233 |
| parent | 0cf756c80a4bc1b0459bc81bf8071891f12c3738 |
| signature |
2 files changed, 7 insertions(+), 5 deletions(-)
README.md+1-1| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 |  |
| 4 | 4 | [](https://github.com/nektro/zig-extras/blob/master/LICENSE) |
| 5 | 5 | [](https://github.com/sponsors/nektro) |
| 6 | [](https://ziglang.org/) | |
| 6 | [](https://ziglang.org/) | |
| 7 | 7 | [](https://github.com/nektro/zigmod) |
| 8 | 8 | |
| 9 | 9 | An assortment of random utility functions that aren't in std and don't deserve their own package. |
src/pipe.zig+6-4| ... | ... | @@ -3,10 +3,12 @@ const string = []const u8; |
| 3 | 3 | const extras = @import("./lib.zig"); |
| 4 | 4 | |
| 5 | 5 | pub fn pipe(reader_from: anytype, writer_to: anytype) !void { |
| 6 | var buf: [std.heap.page_size_min]u8 = undefined; | |
| 7 | var fifo = std.fifo.LinearFifo(u8, .Slice).init(&buf); | |
| 8 | defer fifo.deinit(); | |
| 9 | try fifo.pump(reader_from, writer_to); | |
| 6 | var buf: [4096]u8 = undefined; | |
| 7 | while (true) { | |
| 8 | const n = try reader_from.read(&buf); | |
| 9 | if (n == 0) break; | |
| 10 | try writer_to.writeAll(buf[0..n]); | |
| 11 | } | |
| 10 | 12 | } |
| 11 | 13 | |
| 12 | 14 | test { |