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 › WipFunction › @"switch" Public Function @"switch" Doc Source 6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542 pub fn @"switch" (
self : *WipFunction ,
val : Value ,
default : Block .Index ,
cases_len : u32 ,
weights : Instruction .BrCond .Weights ,
) Allocator .Error !WipSwitch {
try self .ensureUnusedExtraCapacity (1 , Instruction .Switch , cases_len * 2 );
const instruction = try self .addInst (null , .{
.tag = .@"switch" ,
.data = self .addExtraAssumeCapacity (Instruction .Switch {
.val = val ,
.default = default ,
.cases_len = cases_len ,
.weights = weights ,
}),
});
_ = self .extra .addManyAsSliceAssumeCapacity (cases_len * 2 );
default .ptr (self ).branches += 1 ;
return .{ .index = 0 , .instruction = instruction };
}