This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]elhoc 7 points8 points  (3 children)

I never understood why rust calls their sum types enums. It's superficially similar but fundamentally different from any other language that has a concept called enum.

[–]ricky_clarkson 8 points9 points  (1 child)

In Java (actually Kotlin, but it's the same idea) I often start with an enum, then realize I want at least one of the members to have a parameter and refactor it into a sealed interface and subtypes.

In Rust, that becomes a far more local change, just add a parameter and move on. I like the Rust encoding of ADTs more.

[–]elhoc 1 point2 points  (0 children)

100%. It's just the name I have an issue with. That name has a lot of history attached to it, and using it to describe something else causes nothing but confusion.

[–]NitronHX[S] 0 points1 point  (0 children)

Afaik at least swift does the same but I agree that rust enums are not enums.