#Thoughts on switching on strings?

1 messages · Page 1 of 1 (latest)

brisk lake
#

you can use @"enum" instead of enum as the enum field. or you can use a ComptimeStringMap rather than stringToEnum.

brisk lake
#

StaticStringMap doesn't need an allocator - use initComptime

#

example:

test "list literal of list literals" {
    const map = TestMap.initComptime(&.{
        .{ "these", .D },
        .{ "have", .A },
        .{ "nothing", .B },
        .{ "incommon", .C },
        .{ "samelen", .E },
    });
    try testing.expect(null == map.get("NOTHING"));
}