pub fn print(a: Allocator, comptime format: []const u8, args: anytype) Error![]u8 a: Allocatorformat: []const u8argsOutOfMemory486
487
488
489
490
491
492
493pub fn print(a: Allocator, comptime format: []const u8, args: anytype) Error![]u8 {
var aw = try std.Io.Writer.Allocating.initCapacity(a, format.len);
defer aw.deinit();
aw.writer.print(format, args) catch |err| switch (err) {
error.WriteFailed => return error.OutOfMemory,
};
return aw.toOwnedSlice();
}
Allocates a formatted string which is returned on success.
Returned slice can be deallocated with
free. If an arena-style allocator is used instead, such asstd.heap.ArenaAllocator, then no call tofreeis necessary.See
std.Io.Writer.print.