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 › llvm › Builder › WipFunction › extraDataTrail Private Type Function extraDataTrail Doc Source Private Type Function std.zig.llvm.Builder.WipFunction.extraDataTrail
fn extraDataTrail (
self : *const WipFunction ,
comptime T : type ,
index : Instruction .ExtraIndex ,
) struct File zig/llvm/Builder.zig: 8155
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187 fn extraDataTrail (
self : *const WipFunction ,
comptime T : type ,
index : Instruction .ExtraIndex ,
) struct { data : T , trail : ExtraDataTrail } {
var result : T = undefined ;
const info = @typeInfo (T ).@"struct" ;
inline for (
info .field_names ,
info .field_types ,
self .extra .items [index ..][0 ..info .field_names .len ],
) |field_name , field_type , value |
@field (result , field_name ) = switch (field_type ) {
u32 => value ,
Alignment ,
AtomicOrdering ,
Block .Index ,
FunctionAttributes ,
Type ,
Value ,
Instruction .BrCond .Weights ,
=> @fromBackingInt (value ),
MemoryAccessInfo ,
Instruction .Alloca .Info ,
Instruction .Call .Info ,
=> @bitCast (value ),
else => @compileError ("bad field type: " ++ field_name ++ ": " ++ @typeName (field_type )),
};
return .{
.data = result ,
.trail = .{ .index = index + @as (Type .Item .ExtraIndex , @intCast (info .field_names .len )) },
};
}