Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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

renderFor

Private Function
std.zig.Ast.Render.renderFor
fn renderFor(r: *Render, for_node: Ast.full.For, space: Space) Error!void

Params

Errors

OutOfMemory

Ran out of memory allocating call stack frames to complete rendering.

WriteFailed

Transitive failure from

File

zig/Ast/Render.zig:1499
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
fn renderFor(r: *Render, for_node: Ast.full.For, space: Space) Error!void {
    const tree = r.tree;
    const ais = r.ais;
    const token_tags = tree.tokens.items(.tag);

    if (for_node.label_token) |label| {
        try renderIdentifier(r, label, .none, .eagerly_unquote); // label
        try renderToken(r, label + 1, .space); // :
    }

    if (for_node.inline_token) |inline_token| {
        try renderToken(r, inline_token, .space); // inline
    }

    try renderToken(r, for_node.ast.for_token, .space); // if/for/while

    const lparen = for_node.ast.for_token + 1;
    try renderParamList(r, lparen, for_node.ast.inputs, .space);

    var cur = for_node.payload_token;
    const pipe = std.mem.findScalarPos(Token.Tag, token_tags, cur, .pipe).?;
    const capture_trailing_comma = token_tags[@intCast(pipe - 1)] == .comma;

    if (capture_trailing_comma)
        try ais.pushIndent(.normal);
    try renderToken(r, cur - 1, if (capture_trailing_comma) .newline else .none); // |
    while (true) {
        if (token_tags[cur] == .asterisk) {
            try renderToken(r, cur, .none); // *
            cur += 1;
        }
        try renderIdentifier(r, cur, .none, .preserve_when_shadowing); // identifier
        cur += 1;
        if (token_tags[cur] == .comma) {
            try renderToken(r, cur, if (capture_trailing_comma) .newline else .space); // ,
            cur += 1;
        }
        if (token_tags[cur] == .pipe) {
            break;
        }
    }
    if (capture_trailing_comma)
        ais.popIndent();

    try renderThenElse(
        r,
        cur,
        for_node.ast.then_expr,
        for_node.else_token,
        null,
        for_node.ast.else_expr,
        space,
    );
}