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. Private Type Function

extraData

Private Type Function
std.zig.ErrorBundle.extraData
fn extraData(eb: ErrorBundle, comptime T: type, index: usize) struct

Returns the requested data, as well as the new index which is at the start of the trailers for the object.

File

zig/ErrorBundle.zig:130
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
fn extraData(eb: ErrorBundle, comptime T: type, index: usize) struct { data: T, end: usize } {
    const field_names = @typeInfo(T).@"struct".field_names;
    const field_types = @typeInfo(T).@"struct".field_types;
    var i: usize = index;
    var result: T = undefined;
    inline for (field_names, field_types) |field_name, field_type| {
        @field(result, field_name) = switch (field_type) {
            u32 => eb.extra[i],
            MessageIndex => @as(MessageIndex, @fromBackingInt(@intCast(eb.extra[i]))),
            SourceLocationIndex => @as(SourceLocationIndex, @fromBackingInt(@intCast(eb.extra[i]))),
            else => @compileError("bad field type"),
        };
        i += 1;
    }
    return .{
        .data = result,
        .end = i,
    };
}