4 ms·
I try to use switches only for enums or things with a 1 to 1 simple mapping. Enums to strings for example. Although even there my preference is to use an attrib
by sixothree 7y ago
I try to use switches only for enums or things with a 1 to 1 simple mapping. Enums to strings for example. Although even there my preference is to use an attribute on the enum.
- rswail 7y agoExcept that enumerations are not just "strings as magic numbers". Rust's enumerations (and others) enforce that all the enumerations are dealt with in the match (a superclass of switch, mixing metaphors).