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 › AstGen › unionInit Private Function unionInit Doc Source Private Function std.zig.AstGen.unionInit
fn unionInit (
gz : *GenZir ,
scope : *Scope ,
ri : ResultInfo ,
node : Ast .Node .Index ,
params : []const Ast .Node .Index ,
) InnerError !Zir .Inst .Ref Params Errors File zig/AstGen.zig: 8719
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739 fn unionInit (
gz : *GenZir ,
scope : *Scope ,
ri : ResultInfo ,
node : Ast .Node .Index ,
params : []const Ast .Node .Index ,
) InnerError !Zir .Inst .Ref {
const union_type = try typeExpr (gz , scope , params [0 ]);
const field_name = try comptimeExpr (gz , scope , .{ .rl = .{ .coerced_ty = .slice_const_u8_type } }, params [1 ], .union_field_names );
const field_type = try gz .addPlNode (.field_type_ref , node , Zir .Inst .FieldTypeRef {
.container_type = union_type ,
.field_name = field_name ,
});
const init = try reachableExpr (gz , scope , .{ .rl = .{ .ty = field_type } }, params [2 ], node );
const result = try gz .addPlNode (.union_init , node , Zir .Inst .UnionInit {
.union_type = union_type ,
.init = init ,
.field_name = field_name ,
});
return rvalue (gz , ri , result , node );
}