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 › debugExpressionAssumeCapacity Private Function debugExpressionAssumeCapacity Doc Source Private Function std.zig.llvm.Builder.debugExpressionAssumeCapacity
fn debugExpressionAssumeCapacity (self : *Builder , elements : []const u32 ) Metadata Params self : *Builder elements : []const u32 File zig/llvm/Builder.zig: 14287
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331 fn debugExpressionAssumeCapacity (self : *Builder , elements : []const u32 ) Metadata {
assert (!self .strip );
const Key = struct {
elements : []const u32 ,
};
const Adapter = struct {
builder : *const Builder ,
pub fn hash (_ : @This (), key : Key ) u32 {
var hasher =
comptime std .hash .Wyhash .init (std .hash .int (@backingInt (Metadata .Tag .expression )));
hasher .update (std .mem .sliceAsBytes (key .elements ));
return @truncate (hasher .final ());
}
pub fn eql (ctx : @This (), lhs_key : Key , _ : void , rhs_index : usize ) bool {
if (Metadata .Tag .expression != ctx .builder .metadata_items .items (.tag )[rhs_index ])
return false ;
const rhs_data = ctx .builder .metadata_items .items (.data )[rhs_index ];
var rhs_extra = ctx .builder .metadataExtraDataTrail (Metadata .Expression , rhs_data );
return std .mem .eql (
u32 ,
lhs_key .elements ,
rhs_extra .trail .next (rhs_extra .data .elements_len , u32 , ctx .builder ),
);
}
};
const gop = self .metadata_map .getOrPutAssumeCapacityAdapted (
Key { .elements = elements },
Adapter { .builder = self },
);
if (!gop .found_existing ) {
gop .key_ptr .* = {};
gop .value_ptr .* = {};
self .metadata_items .appendAssumeCapacity (.{
.tag = .expression ,
.data = self .addMetadataExtraAssumeCapacity (Metadata .Expression {
.elements_len = @intCast (elements .len ),
}),
});
self .metadata_extra .appendSliceAssumeCapacity (@ptrCast (elements ));
}
return .{ .index = @intCast (gop .index ), .kind = .node };
}