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: std.mem.Allocator, ) std.mem.Allocator.Error![]const u8
Parameters
component: Component
arena: std.mem.Allocator
Source
pub fn toRawMaybeAlloc(
component: Component,
arena: std.mem.Allocator,
) std.mem.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, "{raw}", .{component})
else
percent_encoded,
};
}