Module sync::channel
Chan<T>: typed channel over the channel built-ins
struct Chan<int> ch = std::Chan::new(16); // T inferred from the target
ch.send(42); // blocks while full; 0 once closed
match (ch.recv()) { // blocks while empty; null once closed and drained
case some(v): ...
case none: ...
}
ch.close();
The language's chan_create/chan_send/chan_recv/chan_close built-ins are untyped: the runtime (channel.sc's _safec_chan* functions) carries fixed 8-byte payload slots and copies exactly 8 bytes per send/recv. Chan<T> fixes the element type and pads T into a full 8-byte slot, so nothing reads or writes past a smaller T. sizeof(T) <= 8 is checked at compile time; for a larger T, send a reference to it (a '?&T' fits on every supported target) and keep the referent alive until received.
Structs
| Chan |