Function renderAlloc [src]

gpa is used for allocating the resulting formatted source code. Caller owns the returned slice of bytes, allocated with gpa.

Prototype

pub fn renderAlloc(tree: Ast, gpa: Allocator) error{OutOfMemory}![]u8

Parameters

tree: Astgpa: Allocator

Possible Errors

OutOfMemory

Source

pub fn renderAlloc(tree: Ast, gpa: Allocator) error{OutOfMemory}![]u8 { var aw: std.Io.Writer.Allocating = .init(gpa); defer aw.deinit(); render(tree, gpa, &aw.writer, .{}) catch |err| switch (err) { error.WriteFailed, error.OutOfMemory => return error.OutOfMemory, }; return aw.toOwnedSlice(); }