Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function

takeDelimiter

Public Function
std.Io.Reader.takeDelimiter
pub fn takeDelimiter(r: *Reader, delimiter: u8) error

Returns a slice of the next bytes of buffered data from the stream until delimiter is found, advancing the seek position past the delimiter.

Returned slice excludes the delimiter. End-of-stream is treated equivalent to a delimiter, unless it would result in a length 0 return value, in which case null is returned instead.

If the delimiter is not found within a number of bytes matching the capacity of this Reader, error.StreamTooLong is returned. In such case, the stream state is unmodified as if this function was never called.

Invalidates previously returned values from peek.

See also:

Params

File

Io/Reader.zig:899
899
900
901
902
903
904
905
906
907
908
909
910
911
pub fn takeDelimiter(r: *Reader, delimiter: u8) error{ ReadFailed, StreamTooLong }!?[]u8 {
    const inclusive = r.peekDelimiterInclusive(delimiter) catch |err| switch (err) {
        error.EndOfStream => {
            const remaining = r.buffer[r.seek..r.end];
            if (remaining.len == 0) return null;
            r.toss(remaining.len);
            return remaining;
        },
        else => |e| return e,
    };
    r.toss(inclusive.len);
    return inclusive[0 .. inclusive.len - 1];
}