News for hackers. Stuff that matters.
Re:Rust 1.100.0 by Xirdus on Thursday November 12, 2026 @03:04PM (#50473385)
Mathematically, types are sets of possible values.

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.

Re:Rust 1.100.0 by boston_clone on Thursday November 12, 2026 @03:29PM (#50473739)
[delayed]
Re:Rust 1.100.0 by rcxdude on Thursday November 12, 2026 @04:15PM (#50474393)
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).
Re:Rust 1.100.0 by afdbcreid on Thursday November 12, 2026 @04:19PM (#50474437)
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.
Re:Rust 1.100.0 by afdbcreid on Thursday November 12, 2026 @05:00PM (#50474931)
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.