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 library itself.

checkFloat

Returns an error if parseNumberLiteral returns .float but parseFloat fails. AstGen relies on parseFloat being unable to fail after calling parseNumberLiteral.

number_literal.checkFloat
fn checkFloat(bytes: []const u8) !void

File

lib/std/zig/number_literal.zig:186

Code

fn checkFloat(bytes: []const u8) !void {
    // Number literals must start with a digit
    if (bytes.len == 0 or !std.ascii.isDigit(bytes[0])) return;

    switch (parseNumberLiteral(bytes)) {
        .float => {
            _ = try std.fmt.parseFloat(f128, bytes);
        },
        else => {},
    }
}