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

consume

Public Function
std.Io.Writer.consume
pub fn consume(w: *Writer, n: usize) usize

Removes the first n bytes from buffer by shifting buffer contents, returning how many bytes are left after consuming the entire buffer, or zero if the entire buffer was not consumed.

Useful for VTable.drain function implementations to implement partial drains.

Params

File

Io/Writer.zig:2405
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
pub fn consume(w: *Writer, n: usize) usize {
    if (n < w.end) {
        const remaining = w.buffer[n..w.end];
        @memmove(w.buffer[0..remaining.len], remaining);
        w.end = remaining.len;
        return 0;
    }
    defer w.end = 0;
    return n - w.end;
}