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 library itself.

fn_error_set

main.fn_error_set
export fn fn_error_set(decl_index: Decl.Index) Ast.Node.OptionalIndex

File

lib/docs/wasm/main.zig:591

Code

export fn fn_error_set(decl_index: Decl.Index) Ast.Node.OptionalIndex {
    const decl = decl_index.get();
    const ast = decl.file.get_ast();
    var buf: [1]Ast.Node.Index = undefined;
    const full = ast.fullFnProto(&buf, decl.ast_node).?;
    const return_type = full.ast.return_type.unwrap().?;
    return switch (ast.nodeTag(return_type)) {
        .error_set_decl => return_type.toOptional(),
        .error_union => ast.nodeData(return_type).node_and_node[0].toOptional(),
        else => .none,
    };
}