10 ms·
Which makes sense because you could (and indeed still will be able to do) write your own uninhabited types very easily in Rust and indeed they're optimised acco
by tialaramex 4d ago
Which makes sense because you could (and indeed still will be able to do) write your own uninhabited types very easily in Rust and indeed they're optimised accordingly. Because Rust has user-defined sum types you could simply write a sum of nothing:
enum MyNeverType {}
...and it's uninhabited, the same way you can write the product of nothing
struct MyUnitType {}
... and its size is zero.
- nextaccountic 4d agoNote, to be more clear, an enum with no variants has no values of that type (can't be constructed), and a struct with no fields has exactly one value of that type
- teiferer 3d agoJust like you would expect from algebra. The empty sum is 0, the empty product is 1.
- aissi 3d ago[flagged]
- nixpulvis 3d agoA reference to a value isn't the same as the value itself. I'm confused the point you're making here.
- horseduck 3d agotialaramex got it wrong even at the type theory level, a size of 0 is the wrong focus, the number of elements, 1, should have been the focus.
- kibwen 3d agoI wouldn't say they got it wrong exactly. Uninhabited types aren't equivalent to unit types, but in terms of Rust they're both classified as zero-size, and I suspect they were just pointing out that Rust has optimized and special-cased zero-sized types accordingly since time immemorial.
- red75prime 3d ago> remember to kill all pedophile murderers like... What's this bullshit?