authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-05 16:44:37-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-05 16:50:41-08:00
log7246eee1e706b142abf8183e960fd692fde52bb0
treecd7e20981d1e8b91e0c21ffd2e89ee33a36ed3e7
parentee21a1f988f05a5d45bcb1724095c27cc2c7259b

std.Progress: add Node.startFmt

convenience method for starting a child node with a formatted string as a name.

1 files changed, 6 insertions(+), 0 deletions(-)

lib/std/Progress.zig+6
...@@ -325,6 +325,12 @@ pub const Node = struct {...@@ -325,6 +325,12 @@ pub const Node = struct {
325 return init(@enumFromInt(free_index), parent, name, estimated_total_items);325 return init(@enumFromInt(free_index), parent, name, estimated_total_items);
326 }326 }
327327
328 pub fn startFmt(node: Node, estimated_total_items: usize, comptime format: []const u8, args: anytype) Node {
329 var buffer: [max_name_len]u8 = undefined;
330 const name = std.fmt.bufPrint(&buffer, format, args) catch &buffer;
331 return Node.start(node, name, estimated_total_items);
332 }
333
328 /// This is the same as calling `start` and then `end` on the returned `Node`. Thread-safe.334 /// This is the same as calling `start` and then `end` on the returned `Node`. Thread-safe.
329 pub fn completeOne(n: Node) void {335 pub fn completeOne(n: Node) void {
330 const index = n.index.unwrap() orelse return;336 const index = n.index.unwrap() orelse return;