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.

writeValue

Ir.writeValue
fn writeValue(ir: Ir, val: Interner.Ref, term: std.Io.Terminal) !void

File

Code

fn writeValue(ir: Ir, val: Interner.Ref, term: std.Io.Terminal) !void {
    const w = term.writer;
    try term.setColor(LITERAL);
    const key = ir.interner.get(val);
    switch (key) {
        .null => return w.writeAll("nullptr_t"),
        .int => |repr| switch (repr) {
            inline else => |x| return w.print("{d}", .{x}),
        },
        .float => |repr| switch (repr) {
            inline else => |x| return w.print("{d}", .{@as(f64, @floatCast(x))}),
        },
        .bytes => |b| return std.zig.stringEscape(b, w),
        else => unreachable, // not a value
    }
}