pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) K: typeContext: type2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236pub fn getAutoHashFn(comptime K: type, comptime Context: type) (fn (Context, K) u32) {
return struct {
fn hash(ctx: Context, key: K) u32 {
_ = ctx;
if (std.meta.hasUniqueRepresentation(K)) {
return @truncate(Wyhash.hash(0, std.mem.asBytes(&key)));
} else {
var hasher = Wyhash.init(0);
autoHash(&hasher, key);
return @truncate(hasher.final());
}
}
}.hash;
}