#std.EnumMap(Enum, Struct), value can be null even though not marked as optional

1 messages · Page 1 of 1 (latest)

silent light
#

std.EnumMap(Struct, Struct), value can be null even though not marked as optional

fiery nimbus
#

are you referencing that code anywhere? its not valid

#

the whole point of EnumMap is for the index to be an enum, you cant use a u8

#

regardless though, null is valid there, its just have the init function is done

#

because the list youre giving to init is not accepting the type you used directly

#

it wraps it in an optional

silent light
#

std.EnumMap(Enum, Struct), value can be null even though not marked as optional

fiery nimbus
#

i dont see how this is hidden behavior its a function doing stuff

#

its so you can leave a field uninitialized

#

imo the more "hidden behavior" is that you can omit the field entirely

open axle
#

You want EnumArray

open axle
#

EnumArray doesn't have optional values

#

EnumMap does

#

Did U want all pairs to be initialised?

#

Because enum map stores optional values

#

enum array does not