commit 7246eee1e706b142abf8183e960fd692fde52bb0 (tree)
parent ee21a1f988f05a5d45bcb1724095c27cc2c7259b
Author: Andrew Kelley <andrew@ziglang.org>
Date: Thu, 5 Feb 2026 16:44:37 -0800
std.Progress: add Node.startFmt
convenience method for starting a child node with a formatted string as
a name.
Diffstat:
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git a/lib/std/Progress.zig b/lib/std/Progress.zig
@@ -325,6 +325,12 @@ pub const Node = struct {
return init(@enumFromInt(free_index), parent, name, estimated_total_items);
}
+ pub fn startFmt(node: Node, estimated_total_items: usize, comptime format: []const u8, args: anytype) Node {
+ var buffer: [max_name_len]u8 = undefined;
+ const name = std.fmt.bufPrint(&buffer, format, args) catch &buffer;
+ return Node.start(node, name, estimated_total_items);
+ }
+
/// This is the same as calling `start` and then `end` on the returned `Node`. Thread-safe.
pub fn completeOne(n: Node) void {
const index = n.index.unwrap() orelse return;