aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-12-21 17:09:22 +0000
committergingerBill <gingerBill@users.noreply.github.com>2025-12-21 17:09:22 +0000
commit998da2c2da72853cff9ceeb86d07ad20bb81a8c6 (patch)
tree38e2b22cf7851c3808905878689ab2395abfa190
parent06076e02c0acd0559eeefb32a1a420e4d7243aa7 (diff)
Add `reflect.default_map_hash_by_ptr`
-rw-r--r--core/reflect/reflect.odin10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/reflect/reflect.odin b/core/reflect/reflect.odin
index 5fbff08c2..378c50ff0 100644
--- a/core/reflect/reflect.odin
+++ b/core/reflect/reflect.odin
@@ -2003,4 +2003,14 @@ equal :: proc(a, b: any, including_indirect_array_recursion := false, recursion_
runtime.print_typeid(a.id)
runtime.print_string("\n")
return true
+}
+
+
+@(require_results)
+default_map_hash_by_ptr :: proc(ptr: ^$T, seed: uintptr = runtime.INITIAL_HASH_SEED) -> uintptr where intrinsics.type_is_comparable(T) {
+ assert(ptr != nil)
+
+ info := intrinsics.type_map_info(map[T]struct{})
+
+ return info.key_hasher(ptr, seed)
} \ No newline at end of file