this post was submitted on 19 Jun 2023
4 points (100.0% liked)
Rust Programming
8191 readers
3 users here now
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
You reminded me of a deeply amusing story of solving the 4 queens problem with just the type system.
I was actually vaguely thinking that for playing cards, there's no actual way to do maths on it (like you can't add an Ace to a Jack, or a Joker to a Queen). Are Aces high? Is the 2 worth 2 points or something else? So maybe OP is better off just defining the ranks manually (A, 2, 3 ... J, Q K) and then separate out any points calculations. In that sense, OP might actually want the game rules encoded into the type system.
EDIT: Also, nice, I remember reading that story.