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. Private Function
Find the result type for a cast builtin given the result location. If the location does not have a known result type, emits an error on the given node.
fnresultTypeForCast(rl: Loc, gz: *GenZir, node: Ast.Node.Index, builtin_name: []constu8) !Zir.Inst.Ref {
constastgen = gz.astgen;
if (tryrl.resultType(gz, node)) |ty| returnty;
switch (rl) {
.destructure => |destructure| returnastgen.failNodeNotes(node, "{s} must have a known result type", .{builtin_name}, &.{
tryastgen.errNoteNode(destructure.src_node, "destructure expressions do not provide a single result type", .{}),
tryastgen.errNoteNode(node, "use @as to provide explicit result type", .{}),
}),
else => returnastgen.failNodeNotes(node, "{s} must have a known result type", .{builtin_name}, &.{
tryastgen.errNoteNode(node, "use @as to provide explicit result type", .{}),
}),
}
}
Find the result type for a cast builtin given the result location. If the location does not have a known result type, emits an error on the given node.