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 › attrGeneric Private Function attrGeneric Doc Source Private Function std.zig.llvm.Builder.attrGeneric
fn attrGeneric (self : *Builder , data : []const u32 ) Allocator .Error !u32 Params File zig/llvm/Builder.zig: 12266
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288 fn attrGeneric (self : *Builder , data : []const u32 ) Allocator .Error !u32 {
try self .attributes_map .ensureUnusedCapacity (self .gpa , 1 );
try self .attributes_indices .ensureUnusedCapacity (self .gpa , 1 );
try self .attributes_extra .ensureUnusedCapacity (self .gpa , data .len );
const Adapter = struct {
builder : *const Builder ,
pub fn hash (_ : @This (), key : []const u32 ) u32 {
return @truncate (std .hash .Wyhash .hash (1 , std .mem .sliceAsBytes (key )));
}
pub fn eql (ctx : @This (), lhs_key : []const u32 , _ : void , rhs_index : usize ) bool {
const start = ctx .builder .attributes_indices .items [rhs_index ];
const end = ctx .builder .attributes_indices .items [rhs_index + 1 ];
return std .mem .eql (u32 , lhs_key , ctx .builder .attributes_extra .items [start ..end ]);
}
};
const gop = self .attributes_map .getOrPutAssumeCapacityAdapted (data , Adapter { .builder = self });
if (!gop .found_existing ) {
self .attributes_extra .appendSliceAssumeCapacity (data );
self .attributes_indices .appendAssumeCapacity (@intCast (self .attributes_extra .items .len ));
}
return @intCast (gop .index );
}