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.

extraDataTrail

Interner.extraDataTrail
fn extraDataTrail(i: *const Interner, comptime T: type, index: usize) struct

File

Code

fn extraDataTrail(i: *const Interner, comptime T: type, index: usize) struct { data: T, end: u32 } {
    var result: T = undefined;
    const info = @typeInfo(T).@"struct";
    inline for (info.field_names, info.field_types, 0..) |field_name, field_type, field_i| {
        const int32 = i.extra.items[field_i + index];
        @field(result, field_name) = switch (field_type) {
            Ref => @fromBackingInt(@intCast(int32)),
            u32 => int32,
            else => @compileError("bad field type: " ++ @typeName(field_type)),
        };
    }
    return .{
        .data = result,
        .end = @intCast(index + info.field_names.len),
    };
}