This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 8/19/2026.

Switch

~import std/switch

Koru Standard Library: switch — compile-time exact-value dispatch as control

switch.kz · 1 tors · ~[comptime]

Koru Standard Library: switch — compile-time exact-value dispatch as control · 15 more lines
Koru Standard Library: switch — compile-time exact-value dispatch as control flow. Sibling of std/regex:match: same branch surface, but dispatches on a single scalar value with a native Zig switch instead of a regex DFA. std/switch:char(ch) | `a` c |> got-a(c) | `b` c |> got-b(c) | no-match |> other() The branch head is the opaque backtick string. The transform parses it as: - single char: `a` - inclusive range: `a-z` - set of chars: `aeiou` and emits a Zig switch on the dispatched value. First matching arm wins; `no-match` is the optional fallback.

char

comptimetransform koru_std/switch.kz:43