Switching on Strings in Zig

Newcomers to Zig will quickly learn that you can't switch on a string (i.e. []const u8 ). The following code gives us the unambiguous error message cannot switch on strings : switch (color) { "red" => {}, "blue" => {}, "green" => {}, "pink" => {}, else => {}, } I've seen two explanations for why this isn't supported. The first is that there's ambiguity around string identity. Are two strings only…