#I am not sure to understand the `NoEofError` in readUntilDelimiter, it means EOF has been reached ?

1 messages · Page 1 of 1 (latest)

humble ivy
#

Since it says no EOF, it confuses me xD
I want EOF to be an error in my code, but I dont know what NoEofError means, or I should use readUntilDelimiterEof and do orelse return error.EOF ?

#
// try to read a u8 from user input
fn readUInt() !u8 {
    var stdin = std.io.getStdIn().reader();
    var buff: [5]u8 = undefined;
    const input = stdin.readUntilDelimiterOrEof(&buff, '\n') catch |err| {
        if (err == error.StreamTooLong) while (try stdin.readByte() != '\n') {};
        return err;
    } orelse {
        std.debug.print("\rerror: End of Input reached\n", .{});
        std.process.exit(1);
    };
    return try std.fmt.parseUnsigned(u8, input, 10);
}
#

basically trying to read a u8 from stdin

stable pendant
#

NoEofError is the set of all errors that can be returned from a *NoEof function, it is not the name of any specific error