|
|
|
|
|
by ForkMeOnTinder
1085 days ago
|
|
Here's how you return a hashmap from a function: fn buildMap(allocator: std.mem.Allocator) !std.AutoHashMap(u64, u64) {
var result = std.AutoHashMap(u64, u64).init(allocator);
errdefer result.deinit();
try result.put(10, 100);
try result.put(20, 200);
return result;
}
Your #1 option should be possible once Zig has comptime allocators -- it's on the roadmap, but not possible yet iirc. |
|
Cheers for letting me know though!