Function toRawMaybeAlloc [src]

Allocates the result with arena only if needed, so the result should not be freed.

Prototype

pub fn toRawMaybeAlloc(component: Component, arena: Allocator) Allocator.Error![]const u8

Parameters

component: Componentarena: Allocator

Source

pub fn toRawMaybeAlloc(component: Component, arena: Allocator) Allocator.Error![]const u8 { return switch (component) { .raw => |raw| raw, .percent_encoded => |percent_encoded| if (std.mem.indexOfScalar(u8, percent_encoded, '%')) |_| try std.fmt.allocPrint(arena, "{f}", .{std.fmt.alt(component, .formatRaw)}) else percent_encoded, }; }