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 › Parse › finishAssignDestructureExpr Private Function finishAssignDestructureExpr Doc Source Private Function std.zig.Parse.finishAssignDestructureExpr
fn finishAssignDestructureExpr (p : *Parse , first_lhs : Node .Index ) !Node .Index Params File zig/Parse.zig: 1473
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504 fn finishAssignDestructureExpr (p : *Parse , first_lhs : Node .Index ) !Node .Index {
const scratch_top = p .scratch .items .len ;
defer p .scratch .shrinkRetainingCapacity (scratch_top );
try p .scratch .append (p .gpa , first_lhs );
while (p .eatToken (.comma )) |_ | {
const expr = try p .expectExpr ();
try p .scratch .append (p .gpa , expr );
}
const equal_token = try p .expectToken (.equal );
const rhs = try p .expectExpr ();
const lhs_count = p .scratch .items .len - scratch_top ;
assert (lhs_count > 1 ); // we already had first_lhs, and must have at least one more lvalue
const extra_start : ExtraIndex = @fromBackingInt (@intCast (p .extra_data .items .len ));
try p .extra_data .ensureUnusedCapacity (p .gpa , lhs_count + 1 );
p .extra_data .appendAssumeCapacity (@intCast (lhs_count ));
p .extra_data .appendSliceAssumeCapacity (@ptrCast (p .scratch .items [scratch_top ..]));
return p .addNode (.{
.tag = .assign_destructure ,
.main_token = equal_token ,
.data = .{ .extra_and_node = .{
extra_start ,
rhs ,
} },
});
}