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 standard library.
std › zig › ErrorBundle › extraData Private Type Function extraData Doc Source Private Type Function std.zig.ErrorBundle.extraData
fn extraData (eb : ErrorBundle , comptime T : type , index : usize ) struct 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 ,
};
}
Returns the requested data, as well as the new index which is at the start of the trailers for the object.