Hasty Briefsbeta

Partially Matching Zig Enums

15 days ago
  • #Zig
  • #Enums
  • #Programming
  • Discusses handling common code for several variants in Zig enums.
  • Highlights the awkwardness of refactoring enums for common code scenarios.
  • Introduces a runtime panic solution for the AB problem in Zig.
  • Presents a compiler-checked solution using `inline .a, .b` and `comptime unreachable`.
  • Explains how `comptime unreachable` ensures compile-time failure for unreachable branches.
  • Demonstrates that adding a bug fails compilation as intended.