Dynamic string formatting?

argument (position), width, and precision can be specified at runtime as named format arguments.
The fill character is specified only at comptime as part of the format string.

Example:

const std = @import("std");

pub fn main() void {
    std.debug.print("{[value]s:_^[width]}\n", .{
        .value = "hi",
        .width = 10,
    });
}

prints: ____hi____

6 Likes