Void is surprisingly useful.
Void is surprisingly useful.
Posted Sep 9, 2026 14:52 UTC (Wed) by alx.manpages (subscriber, #145117)In reply to: Void is surprisingly useful. by iabervon
Parent article: Stabilizing Rust's never type
"void (*)(int)" is "function that takes int and calling it is a statement rather than an expression"
void functions still produce expressions. This can be seen in the comma operator:
void f(void);
42, f(), 42;
exit() returns void, but it's still usable as an expression. You just can't assign it to something, because variables of type void are not allowed. But that doesn't make them statements.
