From 45d7dfa8333880ffa0a318723d22a0072bd32b3f Mon Sep 17 00:00:00 2001 From: Constantin Bilz Date: Thu, 19 Oct 2023 12:42:44 +0200 Subject: [PATCH] std.hash_map: add `const` attribute to StringIndexContext.bytes and ... StringIndexAdapter.bytes Without this change, constructing a Context/Adapter for a `const` string table requires a `@constCast`. --- lib/std/hash_map.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/hash_map.zig b/lib/std/hash_map.zig index 91d07c2eb0..43a631baf5 100644 --- a/lib/std/hash_map.zig +++ b/lib/std/hash_map.zig @@ -92,7 +92,7 @@ pub fn hashString(s: []const u8) u64 { } pub const StringIndexContext = struct { - bytes: *std.ArrayListUnmanaged(u8), + bytes: *const std.ArrayListUnmanaged(u8), pub fn eql(self: @This(), a: u32, b: u32) bool { _ = self; @@ -106,7 +106,7 @@ pub const StringIndexContext = struct { }; pub const StringIndexAdapter = struct { - bytes: *std.ArrayListUnmanaged(u8), + bytes: *const std.ArrayListUnmanaged(u8), pub fn eql(self: @This(), a_slice: []const u8, b: u32) bool { const b_slice = mem.sliceTo(@as([*:0]const u8, @ptrCast(self.bytes.items.ptr)) + b, 0);