mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
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`.
This commit is contained in:
parent
1631dc923d
commit
45d7dfa833
@ -92,7 +92,7 @@ pub fn hashString(s: []const u8) u64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub const StringIndexContext = struct {
|
pub const StringIndexContext = struct {
|
||||||
bytes: *std.ArrayListUnmanaged(u8),
|
bytes: *const std.ArrayListUnmanaged(u8),
|
||||||
|
|
||||||
pub fn eql(self: @This(), a: u32, b: u32) bool {
|
pub fn eql(self: @This(), a: u32, b: u32) bool {
|
||||||
_ = self;
|
_ = self;
|
||||||
@ -106,7 +106,7 @@ pub const StringIndexContext = struct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub const StringIndexAdapter = 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 {
|
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);
|
const b_slice = mem.sliceTo(@as([*:0]const u8, @ptrCast(self.bytes.items.ptr)) + b, 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user