Re:Rust 1.100.0
by boston_clone on Thursday November 12, 2026 @03:29PM
(#50473739)
[delayed]
Rust does have https://doc.rust-lang.org/std/any/trait.Any.html but it's not quite the same thing (for one thing, it's not actually all types).
Also called top and bottom types, for this reason.
Re:Rust 1.100.0
by steveklabnik on Thursday November 12, 2026 @04:31PM
(#50474591)
Any is not a top type and ! is not a bottom type, actually. They are sort of similar from a lay perspective if you squint, though.
Why not? I mean if you refer to Rust specifically, yes, because there is no subtyping except for lifetimes, only coercion (and `Any` also cannot contain any type). But in general, why not?
Re:Rust 1.100.0
by steveklabnik on Thursday November 12, 2026 @05:14PM
(#50475106)
I am speaking about Rust specifically, yes.
Any type (like in TypeScript; Rust doesn't have one) is a set of every possible value; a supertype of all types. Every expression regardless of type can be assigned to a variable of type any.
The opposite is the never type, which is an empty set; no value is of type never. Per set theory, an empty set is a subset of every set, which makes the never type a subtype of all types. An expression of type never can be assigned to every variable regardless of type.
If never type has no values, then how can an expression have never type? Easy: it must never evaluate. Infinite loops, unconditional panics/exceptions, process exit/abort, etc. Also, generics - you can have Vec<!> that's always empty, Result<T,!> that can never be an error, etc.