authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-20 17:15:09-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-22 09:41:43-07:00
logaf0a02a2de8fad56029cccbfeb6254a2c2169b51
treea0d09dbe06b7720d92ff17142941391a400b21e8
parent03a6892189891f1566b9e63780129834bea7eb1e

std.Io: delete FindByteWriter

dead

2 files changed, 0 insertions(+), 43 deletions(-)

lib/std/Io.zig-3
...@@ -462,9 +462,6 @@ pub const bitReader = @import("Io/bit_reader.zig").bitReader;...@@ -462,9 +462,6 @@ pub const bitReader = @import("Io/bit_reader.zig").bitReader;
462pub const BitWriter = @import("Io/bit_writer.zig").BitWriter;462pub const BitWriter = @import("Io/bit_writer.zig").BitWriter;
463pub const bitWriter = @import("Io/bit_writer.zig").bitWriter;463pub const bitWriter = @import("Io/bit_writer.zig").bitWriter;
464464
465pub const FindByteWriter = @import("Io/find_byte_writer.zig").FindByteWriter;
466pub const findByteWriter = @import("Io/find_byte_writer.zig").findByteWriter;
467
468pub const tty = @import("Io/tty.zig");465pub const tty = @import("Io/tty.zig");
469466
470/// A Writer that doesn't write to anything.467/// A Writer that doesn't write to anything.
lib/std/Io/find_byte_writer.zig deleted-40
...@@ -1,40 +0,0 @@
1const std = @import("../std.zig");
2const io = std.io;
3const assert = std.debug.assert;
4
5/// A Writer that returns whether the given character has been written to it.
6/// The contents are not written to anything.
7pub fn FindByteWriter(comptime UnderlyingWriter: type) type {
8 return struct {
9 const Self = @This();
10 pub const Error = UnderlyingWriter.Error;
11 pub const Writer = io.GenericWriter(*Self, Error, write);
12
13 underlying_writer: UnderlyingWriter,
14 byte_found: bool,
15 byte: u8,
16
17 pub fn writer(self: *Self) Writer {
18 return .{ .context = self };
19 }
20
21 fn write(self: *Self, bytes: []const u8) Error!usize {
22 if (!self.byte_found) {
23 self.byte_found = blk: {
24 for (bytes) |b|
25 if (b == self.byte) break :blk true;
26 break :blk false;
27 };
28 }
29 return self.underlying_writer.write(bytes);
30 }
31 };
32}
33
34pub fn findByteWriter(byte: u8, underlying_writer: anytype) FindByteWriter(@TypeOf(underlying_writer)) {
35 return FindByteWriter(@TypeOf(underlying_writer)){
36 .underlying_writer = underlying_writer,
37 .byte = byte,
38 .byte_found = false,
39 };
40}