Commit b6fd34aa46

Ryan G <burgerindividual@proton.me>
2024-06-21 01:22:39
std.static_string_map: Cast length of input for runtime initialization
1 parent b8890f8
Changed files (1)
lib/std/static_string_map.zig
@@ -119,7 +119,7 @@ pub fn StaticStringMapWithEql(
             kvs.* = .{
                 .keys = sorted_keys.ptr,
                 .values = sorted_vals.ptr,
-                .len = kvs_list.len,
+                .len = @intCast(kvs_list.len),
             };
             self.kvs = kvs;
 
@@ -270,13 +270,14 @@ const testing = std.testing;
 const test_alloc = testing.allocator;
 
 test "list literal of list literals" {
-    const slice = [_]TestKV{
+    const slice: []const TestKV = &.{
         .{ "these", .D },
         .{ "have", .A },
         .{ "nothing", .B },
         .{ "incommon", .C },
         .{ "samelen", .E },
     };
+
     const map = TestMap.initComptime(slice);
     try testMap(map);
     // Default comparison is case sensitive