logoalt Hacker News

dlubarovyesterday at 8:52 PM2 repliesview on HN

Moreover, Rust traits' associated constants/types get in the way of having a proper bottom type. What would <! as Iterator>::Item be? (In Scala I think it just doesn't compile?)


Replies

SkiFire13yesterday at 10:57 PM

Not only that, if you have `trait Foo: Iterator<Item = u8>` and `trait Bar: Iterator<Item = i32>` how could `!` implement both of them? It would simply make the language incoherent.

10000truthsyesterday at 11:17 PM

> What would <! as Iterator>::Item be?

Another ! makes sense to me here. Are there any cases where it doesn't work to auto-assign ! to all associated types of a ! trait impl? Associated constants might require some mechanism similar to `compile_error!()`.