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 › getOrPutConstantNoExtraAssumeCapacity Private Type Function getOrPutConstantNoExtraAssumeCapacity Doc Source Private Type Function std.zig.llvm.Builder.getOrPutConstantNoExtraAssumeCapacity
fn getOrPutConstantNoExtraAssumeCapacity (
self : *Builder ,
item : Constant .Item ,
) struct File zig/llvm/Builder.zig: 13072
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095 fn getOrPutConstantNoExtraAssumeCapacity (
self : *Builder ,
item : Constant .Item ,
) struct { new : bool , constant : Constant } {
const Adapter = struct {
builder : *const Builder ,
pub fn hash (_ : @This (), key : Constant .Item ) u32 {
return @truncate (std .hash .Wyhash .hash (
std .hash .int (@backingInt (key .tag )),
std .mem .asBytes (&key .data ),
));
}
pub fn eql (ctx : @This (), lhs_key : Constant .Item , _ : void , rhs_index : usize ) bool {
return std .meta .eql (lhs_key , ctx .builder .constant_items .get (rhs_index ));
}
};
const gop = self .constant_map .getOrPutAssumeCapacityAdapted (item , Adapter { .builder = self });
if (!gop .found_existing ) {
gop .key_ptr .* = {};
gop .value_ptr .* = {};
self .constant_items .appendAssumeCapacity (item );
}
return .{ .new = !gop .found_existing , .constant = @fromBackingInt (@intCast (gop .index )) };
}