|
|
Log in / Subscribe / Register

switch

switch

Posted Sep 20, 2021 10:42 UTC (Mon) by tialaramex (subscriber, #21167)
In reply to: switch by HelloWorld
Parent article: Cro: Maintain it With Zig

Exhaustiveness in C is really hard because the enumerated type is just a funny way to spell an integer as explained in the other sub-thread.

Obviously rustc turns your simply enumerated type into an integer in the machine code too, but this happens in an IR after you can't touch it, so the only rule needed to avoid setting yourself on fire is "No unsafe code" ie write #![forbid(unsafe_code)] and you're done.


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds