corrode Rust Consulting Blog company blog
Using enums to represent state in Rust
Many Rust beginners with a background in systems programming tend to use bool (or even u8 – an 8-bit unsigned integer type) to represent “state”. For example, how about a bool to indicate whether a user is active or not? struct User { // ... …
- Points
- 114
- HN comments
- 87
- Submissions
- 1
- Cited by
- 0 commenters
Software EngineeringProgramming Languages2023
On Hacker News
| Submitted | Title on HN | Points | Comments |
|---|---|---|---|
| Sep 22, 2023 | Using enums to represent state in Rust by bitshifta | 114 | 87 |