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.

extraData

Document.extraData
pub fn extraData(doc: Document, comptime T: type, index: ExtraIndex) ExtraData(T)

File

lib/docs/wasm/markdown/Document.zig:172

Code

pub fn extraData(doc: Document, comptime T: type, index: ExtraIndex) ExtraData(T) {
    const info = @typeInfo(T).@"struct";
    var i: usize = @backingInt(index);
    var result: T = undefined;
    inline for (info.field_names, info.field_types) |field_name, field_type| {
        @field(result, field_name) = switch (field_type) {
            u32 => doc.extra[i],
            else => @compileError("bad field type"),
        };
        i += 1;
    }
    return .{ .data = result, .end = i };
}