Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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






Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: