3 ms·
not super familiar with Rust but isn't Option<T> just an union type of null and T? I get the language has special semantics for this compared to a union type bu
by DanielHB 1y ago
not super familiar with Rust but isn't Option<T> just an union type of null and T? I get the language has special semantics for this compared to a union type but it is conceptionally just an union.
For example this is something you can do with typescript.
function(args: Arguments) { ... }
type Arguments = { a: number, b: number } | { a: number, b: string, c: number }
the Arguments { a: 1, b: 1, c: 1 } is not representable.
- qzzi 1y agoI'm pretty sure they're talking about reference counting that depends on the arguments, not about optional arguments or invalid argument combinations.
- 0x457 1y ago> not super familiar with Rust but isn't Option<T> just an union type of null and T? Only if there is a niche optimization happens if T is never null, otherwise it's a tagged union. That's not what you're replying to is about.