Function allocPrint [src]
Prototype
pub fn allocPrint(gpa: Allocator, comptime fmt: []const u8, args: anytype) Allocator.Error![]u8
Parameters
gpa: Allocator
fmt: []const u8
Source
pub fn allocPrint(gpa: Allocator, comptime fmt: []const u8, args: anytype) Allocator.Error![]u8 {
var aw = try Writer.Allocating.initCapacity(gpa, fmt.len);
defer aw.deinit();
aw.writer.print(fmt, args) catch |err| switch (err) {
error.WriteFailed => return error.OutOfMemory,
};
return aw.toOwnedSlice();
}