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 › structTypeAssumeCapacity Private Function structTypeAssumeCapacity Doc Source Private Function std.zig.llvm.Builder.structTypeAssumeCapacity
fn structTypeAssumeCapacity (
self : *Builder ,
comptime kind : Type .Structure .Kind ,
fields : []const Type ,
) Type Params File zig/llvm/Builder.zig: 12079
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117 fn structTypeAssumeCapacity (
self : *Builder ,
comptime kind : Type .Structure .Kind ,
fields : []const Type ,
) Type {
const tag : Type .Tag = switch (kind ) {
.normal => .structure ,
.@"packed" => .packed_structure ,
};
const Adapter = struct {
builder : *const Builder ,
pub fn hash (_ : @This (), key : []const Type ) u32 {
return @truncate (std .hash .Wyhash .hash (
comptime std .hash .int (@backingInt (tag )),
std .mem .sliceAsBytes (key ),
));
}
pub fn eql (ctx : @This (), lhs_key : []const Type , _ : void , rhs_index : usize ) bool {
const rhs_data = ctx .builder .type_items .items [rhs_index ];
if (rhs_data .tag != tag ) return false ;
var rhs_extra = ctx .builder .typeExtraDataTrail (Type .Structure , rhs_data .data );
const rhs_fields = rhs_extra .trail .next (rhs_extra .data .fields_len , Type , ctx .builder );
return std .mem .eql (Type , lhs_key , rhs_fields );
}
};
const gop = self .type_map .getOrPutAssumeCapacityAdapted (fields , Adapter { .builder = self });
if (!gop .found_existing ) {
gop .key_ptr .* = {};
gop .value_ptr .* = {};
self .type_items .appendAssumeCapacity (.{
.tag = tag ,
.data = self .addTypeExtraAssumeCapacity (Type .Structure {
.fields_len = @intCast (fields .len ),
}),
});
self .type_extra .appendSliceAssumeCapacity (@ptrCast (fields ));
}
return @fromBackingInt (@intCast (gop .index ));
}