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

SubmittedTitle on HNPointsComments
Sep 22, 2023Using enums to represent state in Rust by bitshifta11487

More from corrode Rust Consulting Blog

All 9 posts →

Related posts from the same era