16
Jun
In my previous article, I discussed how Rust enums should be strongly considered when the solution benefits from a state machine. The strongest argument for this is the fact that the Rust compiler will inform you when a state variant isn't covered in a match expression. This was stemmed from a state pattern example provided by the official Rust book. The sample scenario they used was an article that was required to go through the status of Draft, PendingReview, and Approved. Using a similar strategy as I explained in my original article, I came up with the following code: post.rs…