| ▲ | jvanderbot 6 hours ago | |
I almost always prefer enums and matches! vs bool parameters. Another way is to implement a Trait that you find useful that encapsulates the logic. And don't forget you can do impl <Enum> {} blocks to add useful functions that execute regardless of which member of the enum you got.
and later:
Or if you hate all that there's always: | ||
| ▲ | J_Shelby_J 5 hours ago | parent [-] | |
If let is probably the closest to a regular bool. For ints you can implement the deref trait on structs. So you can treat YourType(u64) as a u64 without destructing. I couldn’t figure out a way to do that with YouType(bool). | ||