#why does this hang

1 messages · Page 1 of 1 (latest)

mystic birch
#
const std = @import("std");

pub fn main() !void
{
    var manifest = try std.fs.cwd().openFile("temp", .{ .mode = .read_only });
    var manifest_reader_buffer: [4096]u8 = undefined;
    var manifest_reader = manifest.reader(&manifest_reader_buffer);
    while (manifest_reader.interface.takeDelimiterExclusive('\n')) |line|
    {
        try manifest_reader.interface.discardAll(1);
        std.debug.print("{s}:", .{ line });
    }
    else |e| switch (e)
    {
        error.EndOfStream => {},
        else => |unhandled| return unhandled,
    }
}

the content of the file is "1st\n2nd\n3rd" missing the last '\n' and the process hangs after printing "1st:2nd:".
the logic is it obviously can't discard since its reached the end of the stream but why doesn't it return from .discardAll(1) with error.EndOfStream?

grim stone
#

why doesn't it return from .discardAll(1) with error.EndOfStream?
not sure tbh

#

with takeByte(); instead of discardAll(1); it does return EndOfStream