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

hasComment

Private Function
std.zig.Ast.Render.hasComment
fn hasComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool

Returns true if there exists a line comment between any of the tokens from start_token to end_token. This is used to determine if e.g. a fn_proto should be wrapped and have a trailing comma inserted even if there is none in the source.

Params

  • tree: Ast
  • start_token: Ast.TokenIndex
  • end_token: Ast.TokenIndex

File

zig/Ast/Render.zig:2972
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
fn hasComment(tree: Ast, start_token: Ast.TokenIndex, end_token: Ast.TokenIndex) bool {
    for (start_token..end_token) |i| {
        const token: Ast.TokenIndex = @intCast(i);
        const start = tree.tokenStart(token) + tree.tokenSlice(token).len;
        const end = tree.tokenStart(token + 1);
        if (mem.findScalar(u8, tree.source[start..end], '/') != null) return true;
    }

    return false;
}