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 › metadataConstantAssumeCapacity Private Function metadataConstantAssumeCapacity Doc Source Private Function std.zig.llvm.Builder.metadataConstantAssumeCapacity
fn metadataConstantAssumeCapacity (self : *Builder , constant : Constant ) Metadata Params File zig/llvm/Builder.zig: 14452
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482 fn metadataConstantAssumeCapacity (self : *Builder , constant : Constant ) Metadata {
const Adapter = struct {
builder : *const Builder ,
pub fn hash (_ : @This (), key : Constant ) u32 {
var hasher = comptime std .hash .Wyhash .init (std .hash .int (@backingInt (Metadata .Tag .constant )));
hasher .update (std .mem .asBytes (&key ));
return @truncate (hasher .final ());
}
pub fn eql (ctx : @This (), lhs_key : Constant , _ : void , rhs_index : usize ) bool {
if (Metadata .Tag .constant != ctx .builder .metadata_items .items (.tag )[rhs_index ]) return false ;
const rhs_data : Constant = @fromBackingInt (ctx .builder .metadata_items .items (.data )[rhs_index ]);
return rhs_data == lhs_key ;
}
};
const gop = self .metadata_map .getOrPutAssumeCapacityAdapted (
constant ,
Adapter { .builder = self },
);
if (!gop .found_existing ) {
gop .key_ptr .* = {};
gop .value_ptr .* = {};
self .metadata_items .appendAssumeCapacity (.{
.tag = .constant ,
.data = @backingInt (constant ),
});
}
return .{ .index = @intCast (gop .index ), .kind = .node };
}