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 › typeExtraDataTrail Private Type Function typeExtraDataTrail Doc Source Private Type Function std.zig.llvm.Builder.typeExtraDataTrail
fn typeExtraDataTrail (
self : *const Builder ,
comptime T : type ,
index : Type .Item .ExtraIndex ,
) struct File zig/llvm/Builder.zig: 12239
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260 fn typeExtraDataTrail (
self : *const Builder ,
comptime T : type ,
index : Type .Item .ExtraIndex ,
) struct { data : T , trail : TypeExtraDataTrail } {
var result : T = undefined ;
const info = @typeInfo (T ).@"struct" ;
inline for (
info .field_names ,
info .field_types ,
self .type_extra .items [index ..][0 ..info .field_names .len ],
) |field_name , field_type , value |
@field (result , field_name ) = switch (field_type ) {
u32 => value ,
String , Type => @fromBackingInt (value ),
else => @compileError ("bad field type: " ++ @typeName (field_type )),
};
return .{
.data = result ,
.trail = .{ .index = index + @as (Type .Item .ExtraIndex , @intCast (info .field_names .len )) },
};
}