News for hackers. Stuff that matters.
Re:Using enums to represent state in Rust by ewuhic on Friday September 22, 2023 @11:13AM (#37613117)
What would be the equivalent of these patterns in Go?
Re:Using enums to represent state in Rust by fsdjkflsjfsoij on Friday September 22, 2023 @01:52PM (#37615273)
You can't do the exact same thing in Go because Go doesn't have a way to define a sum type yet outside of generic constraints. The closest you can get is using an interface and a type switch but that won't give you exhaustive matching.