From fc9430f56798a53f9393a697f4ccd6bf9981b970 Mon Sep 17 00:00:00 2001 From: Martin Wickham Date: Thu, 3 Jun 2021 15:39:26 -0500 Subject: Breaking hash map changes for 0.8.0 - hash/eql functions moved into a Context object - *Context functions pass an explicit context - *Adapted functions pass specialized keys and contexts - new getPtr() function returns a pointer to value - remove functions renamed to fetchRemove - new remove functions return bool - removeAssertDiscard deleted, use assert(remove(...)) instead - Keys and values are stored in separate arrays - Entry is now {*K, *V}, the new KV is {K, V} - BufSet/BufMap functions renamed to match other set/map types - fixed iterating-while-modifying bug in src/link/C.zig --- src/value.zig | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/value.zig') diff --git a/src/value.zig b/src/value.zig index d8256315da..9c29bdf80c 100644 --- a/src/value.zig +++ b/src/value.zig @@ -1256,6 +1256,23 @@ pub const Value = extern union { return hasher.final(); } + pub const ArrayHashContext = struct { + pub fn hash(self: @This(), v: Value) u32 { + return v.hash_u32(); + } + pub fn eql(self: @This(), a: Value, b: Value) bool { + return a.eql(b); + } + }; + pub const HashContext = struct { + pub fn hash(self: @This(), v: Value) u64 { + return v.hash(); + } + pub fn eql(self: @This(), a: Value, b: Value) bool { + return a.eql(b); + } + }; + /// Asserts the value is a pointer and dereferences it. /// Returns error.AnalysisFail if the pointer points to a Decl that failed semantic analysis. pub fn pointerDeref(self: Value, allocator: *Allocator) error{ AnalysisFail, OutOfMemory }!Value { -- cgit v1.2.3