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 › Parse › addExtra Private Function addExtra Doc Source Private Function std.zig.Parse.addExtra
fn addExtra (p : *Parse , extra : anytype ) Allocator .Error !ExtraIndex Params File zig/Parse.zig: 105
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123 fn addExtra (p : *Parse , extra : anytype ) Allocator .Error !ExtraIndex {
const info = @typeInfo (@TypeOf (extra )).@"struct" ;
try p .extra_data .ensureUnusedCapacity (p .gpa , info .field_names .len );
const result : ExtraIndex = @fromBackingInt (@intCast (p .extra_data .items .len ));
inline for (info .field_names , info .field_types ) |field_name , field_type | {
const data : u32 = switch (field_type ) {
Node .Index ,
Node .OptionalIndex ,
OptionalTokenIndex ,
ExtraIndex ,
=> @backingInt (@field (extra , field_name )),
TokenIndex ,
=> @field (extra , field_name ),
else => @compileError ("unexpected field type" ),
};
p .extra_data .appendAssumeCapacity (data );
}
return result ;
}