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 › Function › extraDataTrail Private Type Function extraDataTrail Doc Source Private Type Function std.zig.llvm.Builder.Function.extraDataTrail
fn extraDataTrail (
self : *const Function ,
comptime T : type ,
index : Instruction .ExtraIndex ,
) struct File zig/llvm/Builder.zig: 6278
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310 fn extraDataTrail (
self : *const Function ,
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 [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 )) },
};
}