const std = @import("std");
test {
const bytes = @embedFile("test.txt");
var stream = std.io.fixedBufferStream(bytes);
const fbs_reader = stream.reader();
const file = try std.fs.cwd().openFile("test.txt", .{});
const file_reader = file.reader();
_ = file_reader; // autofix
const reader = fbs_reader;
// const reader = file_reader;
_ = reader.readByte() catch |err| switch (err) {
error.EndOfStream => std.debug.print("boo", .{}),
else => std.debug.print("ceta", .{}),
};
}
the error set that reader.readByte() produces is ReadError || error{EndOfStream} where ReadError is passed at comptime from the .reader() method of FixedBufferStream or File
for FBS, ReadError is empty while for File it has a bunch of errors like AccessDenied, BrokenPipe, NotOpenForReading, etc
this means that switching on the error produced by .readByte() is a compile error, in this case, using fbs_reader i get compile error saying that the else prong is useless, but removing it means that it is now a compile error with file_reader because the other possible errors were not handled
what do