std.Progress: add Node.startFmt

convenience method for starting a child node with a formatted string as
a name.
This commit is contained in:
Andrew Kelley 2026-02-05 16:44:37 -08:00
parent ee21a1f988
commit 7246eee1e7

View file

@ -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;