I like that in Rust pointers can't even be null, you have to wrap them in a kind of an "enum" (union, ish) of the pointer and Nil value.
1
1
I don't know Haskell, but looking quickly that's more like Rust's "Option" which is in std library, built using the odd "enum"
2
yeah, so Haskell Either seems to be more like Rust's language feature "enum" (only enum can take more than 2 choices...)
1
yes! which I guess is a really generic way of thinking about an enum... rustbyexample.com/custom_typโ€ฆ
1
I'm not convinced. It sounds like a Haskell algebraic data type. Enums should be able to enumerate all their possible values.
2
yeah, it definitely can't enumerate all its possible values, and agree that does seem a weakness.
1
Replying to @frabcus
So, what does rust call a data type which I'd normally call an 'enum' ?

Aug 2, 2016 ยท 9:44 AM UTC

1
Replying to @dsilverstone
hilariously, a "C-like enum", which is a special case enum that has only "unit" types in it rustbyexample.com/custom_typโ€ฆ
1
in my experiments (and I didn't play for long) if you put one non-unit type in your enum, you can no longer cast them to i32