pub fn parseAlloc(allocator: std.mem.Allocator, bytes: []const u8) ParseError![]u8 OutOfMemoryInvalidLiteral360
361
362
363
364
365
366
367
368
369
370pub fn parseAlloc(allocator: std.mem.Allocator, bytes: []const u8) ParseError![]u8 {
var aw: Writer.Allocating = .init(allocator);
defer aw.deinit();
const result = parseWrite(&aw.writer, bytes) catch |err| switch (err) {
error.WriteFailed => return error.OutOfMemory,
};
switch (result) {
.success => return aw.toOwnedSlice(),
.failure => return error.InvalidLiteral,
}
}
Higher level API. Does not return extra info about parse errors. Caller owns returned memory.