3 ms·
Hate to tell you C and C++ switch offers the same compile time safety as Rust here. Just don’t add a “default” clause.
by butterisgood 7y ago
Hate to tell you C and C++ switch offers the same compile time safety as Rust here.
Just don’t add a “default” clause.
- almostdeadguy 7y agoSwitch in C/C++ doesn't enforce mutual exclusivity though. You can forget a "break" statement and fall through multiple cases.
- olliej 7y agoI believe there are warning flags you can turn on for this, and compiler defines/tokens to allow fall through.