3 ms·
The 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 hav
by tialaramex 1y ago
The 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]