#growing an array of strings on comptime

1 messages · Page 1 of 1 (latest)

surreal topaz
#
var field_names: [][]const u8 = &.{};
for (enum_info.fields) |field| {
    field_names = field_names ++ .{field.name};
    // i dont actually know what you could test an enum for lmao
}

this no work since its trying to add [1][]const u8 to [][]const u8, similar error if i snip the &

sullen verge
#

bottom one needs & too

surreal topaz
#

src/core/init.zig:271:58: error: expected indexable; found '*const struct { comptime [:0]const u8 = "DownUp"[0..6] }'
field_names = field_names ++ &.{field.name};

sullen verge
#

&[_][]const u8{

surreal topaz
# sullen verge `&[_][]const u8{`

like this?

src/core/init.zig:271:55: error: expected type '[][]const u8', found '*const [1][]const u8'
                            field_names = field_names ++ &[_][]const u8{field.name};
#

(0.15.2, idk if it matters)

sullen verge
#

lemme find some code, i do this pattern

#

ah try making field_names []const []const u8

surreal topaz
#

worked