#question about HashMaps

1 messages · Page 1 of 1 (latest)

dapper rivet
#

the issue is that front_face is declared const, and so taking an addr-of (&) of it results in a const pointer, which cannot coerce into a mutable slice.

declare front_face as var instead

#

btw, is the key type an enum? if it is and you're not using any special hashing function (and don't need to preserve insertion order), consider using a std.EnumMap instead of a general-purpose hash map - because the maximal number of keys is statically known and indexes can be computed easily, std.EnumMap does not need an allocator, and is much faster

dapper rivet
#
var vertices_map = std.EnumMap(types.faces, []Vec3).init(.{
    .BACK = …,
    .LEFT = …,
    .RIGHT = …,
})

replace the s with the values