Not the most cursed, but a fun one:
const heap_allocator = std.heap.page_allocator;
var buf: [512]u8 = undefined;
const fba = try heap_allocator.create(std.heap.FixedBufferAllocator);
defer heap_allocator.destroy(fba);
fba.buffer = &buf;
fba.end_index = 0;
const stack_allocator = fba.allocator();
const bytes = try stack_allocator.alloc(u8, 3);
std.debug.print("{x}\n", .{bytes});
Heap allocated stack allocator ![]()