4 ms·
its not just that some things you would usually think are control flow are expressions, its also that there are unusual rules around coercing the `noreturn` typ
by throwawaymaths 1y ago
its not just that some things you would usually think are control flow are expressions, its also that there are unusual rules around coercing the `noreturn` type.
- tialaramex 1y agoThe only "unusual" rule here is that Rust offers the zero type addition, but does not provide the (much more complicated) other type additions So Rust does have: String + ! = String But Rust doesn't have: String + i32 = Either<String,i32> Note that the never type ! isn't special here, Rust will also cheerfully: String + Infallible = String or if you were to define your own empty type like so: enum MyEmptyType {} // MyEmptyType has no possible values Now under type arithmetic String + MyEmptyType = String and indeed that works in Rust. Edited: Syntax fix
- deleted 1y ago[deleted]