Was try to understand how the /aro/backend/Interner.zig file used it
const adapter: KeyAdapter = .{ .interner = i };
const gop = try i.map.getOrPutAdapted(gpa, key, adapter);
if (gop.found_existing) return @enumFromInt(gop.index);
try i.items.ensureUnusedCapacity(gpa, 1);
Looking at the language ref for void in hash maps is says all the code that deals with storing and loading voids is deleted.
https://ziglang.org/documentation/master/#void
By using void as the type of the value, the hash map entry type has no value field, and thus the hash map takes up less space. Further, all the code that deals with storing and loading the value is deleted, as seen above.
src/codegen/c/Type.zig also uses one:
const source_info = source_ctype.info(source_pool);
const gop = pool.map.getOrPutAssumeCapacityAdapted(source_ctype, CTypeAdapter{
.pool = pool,
.source_pool = source_pool,
.source_info = source_info,
.pool_adapter = pool_adapter,
});
errdefer _ = pool.map.pop();
const ctype = CType.fromPoolIndex(gop.index);
Looking at the implementation of getOrPutAssumeCapacityAdapted
https://github.com/ziglang/zig/blob/master/lib/std/hash_map.zig#L1360
It creates a hash of the key:
const hash = ctx.hash(key);
Which is verified to match the type specified at comptime, but that doesn't seem to trigger the error that's in the code because the type is void but void is not passed in? Is that because of the " all the code that deals with storing and loading the value is deleted" nature of void? It looks like if does get past the error it is stored as metadata and the rest of it seems to make sense.
It looks like it's being used as an id generator of sort to me, but maybe I misunderstand what's happening.
I'm just curious, trying to understand what this part of the code base is doing.