1. 13
  1. 2

    This looks interesting per se but I guess a list of tuples of values ie a lookup table in them enum could generate both functions at compile time

    1. 2

      It’s funny because I worked on the same AoC problem in Zig, and just ended up using a ComptimeStringMap in lieu of an enum and switch. Not only is the declaration and lookup code much shorter, but I get the “inversion” of keys=>values to values=>keys for free simply by iterating the comptime-generated .kvs struct member.

      That all said, I enjoyed this post only because it dwelled on an interesting comptime use case.