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 › arrayType Private Function arrayType Doc Source Private Function std.zig.AstGen.arrayType
fn arrayType (gz : *GenZir , scope : *Scope , ri : ResultInfo , node : Ast .Node .Index ) !Zir .Inst .Ref Params File zig/AstGen.zig: 3859
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877 fn arrayType (gz : *GenZir , scope : *Scope , ri : ResultInfo , node : Ast .Node .Index ) !Zir .Inst .Ref {
const astgen = gz .astgen ;
const tree = astgen .tree ;
const len_node , const elem_type_node = tree .nodeData (node ).node_and_node ;
if (tree .nodeTag (len_node ) == .identifier and
mem .eql (u8 , tree .tokenSlice (tree .nodeMainToken (len_node )), "_" ))
{
return astgen .failNode (len_node , "unable to infer array size" , .{});
}
const len = try reachableExprComptime (gz , scope , .{ .rl = .{ .coerced_ty = .usize_type } }, len_node , node , .type );
const elem_type = try typeExpr (gz , scope , elem_type_node );
const result = try gz .addPlNode (.array_type , node , Zir .Inst .Bin {
.lhs = len ,
.rhs = elem_type ,
});
return rvalue (gz , ri , result , node );
}