#a way to create a Writer that doesnt error when the buffer is full, just rhrow the rest away?

1 messages · Page 1 of 1 (latest)

worn merlin
#

So I am parsing a file, and I only care about the first 15 bytes of each line. I would like to not write the rest of the line, but i would like to consume it so i can move to the next line.

Is there a way to do that?

#

0.14.1

#
fn do_my_thing(
    reader: std.io.AnyReader,
    buf: []u8,
) !?[]const u8 {
    const read = try reader.read(buf);
    if (read == 0) return null;
    if (read == buf.len)
        try reader.skipUntilDelimiterOrEof('\n');

    return buf;
}