Files
sx/examples/89-enum-arg-through-closure-field.sx
2026-05-18 17:40:10 +03:00

21 lines
374 B
Plaintext

// A closure stored in a struct field receives sub-32-bit enum args
// with the right tag, same as direct or protocol-dispatched calls.
#import "modules/std.sx";
Fmt :: enum { a; b; }
Ctx :: struct {
on: Closure(Fmt) -> void;
}
main :: () -> s32 {
c : Ctx = .{ on = (f: Fmt) => {
n : s64 = xx f;
print("cl f = {}\n", n);
}};
c.on(.b);
c.on(.a);
0;
}