3 ms·
You can, because Rust doesn’t support first class Union, and uses ADTs. Something like Typescript allows you to write “(T | null) | null)” but that is not the s
by rtpg 3y ago
You can, because Rust doesn’t support first class Union, and uses ADTs. Something like Typescript allows you to write “(T | null) | null)” but that is not the same thing as a double-Option’d type.
- ratmice 3y agoRust actually does have an untagged union type, but it generally requires some unsafe to use it, doesn't seem to get much use beyond c/ffi.
- agrover 3y agoIt was added specifically for c/ffi, so this is cool.
- rtpg 3y agobut the untagged union is still an aggregate at the type level right? Your data is a union at runtime, but at the type level it's a distinct thing, yeah? TS in particular is offering bespoke anonymous unions, which is a different sort of beast.
- ratmice 3y agoOf course, rust being nominally typed it is a distinct thing, while TS is structural. But that aspect should affect much more than just unions, (that said I personally know very little about typescript so talk my opinions here with a grain of salt).