|
|
|
|
|
by agons
306 days ago
|
|
Is there a reason the Zig compiler can't perform type-narrowing for `u` within the `U::A(_) | U::B(_)` "guard", rendering just the set of 2 cases entirely necessary and sufficient (obviating the need for any of the solutions in the blog post)? I'm not familiar with Zig, but also ready to find out I'm not as familiar with type systems as I thought. |
|
I think the post would be more helpful if it had a concrete use case. let's say a contrived bytecode VM:
"because comptime", this is effectively the same runtime performance as the common: and this is in a situation where this level of performance optimization is actually valuable to spend time on. it's nice that Zig lets you achieve it while reusing the logic.