Zig 0.17.0-dev (Split by item)

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 library itself.

readOffsetVarInt

git.readOffsetVarInt
fn readOffsetVarInt(r: *Io.Reader) !u64

File

Code

fn readOffsetVarInt(r: *Io.Reader) !u64 {
    const Byte = packed struct { value: u7, has_next: bool };
    var b: Byte = @bitCast(try r.takeByte());
    var value: u64 = b.value;
    while (b.has_next) {
        b = @bitCast(try r.takeByte());
        value = std.math.shlExact(u64, value + 1, 7) catch return error.InvalidFormat;
        value |= b.value;
    }
    return value;
}