Pre pre rfc: <T:!Trait/Concrete>

I found myself in a situation where I wanted to create a mass impl for a library Error class of mine.

I wanted to have a From on anything that implemented Debug. (sure I’m being lazy, but it made sense)

The problem was that my error class also implemented Debug.

This created an ambiguity because the From trait has a mass impl of

impl<T> From<T> for T

Which obiously makes sense. Anything can come from itself.

But this created an ambiguity.

I’d like to be able to write something like

Impl <T:Debug - Self> From<T> for MyErr{
...
}

Or minus some other trait.or type.

Another option for disambiguity would be ranking.

just playing with thoughtts at the moment. currently I have a few specific impl for the errors I need.

There’s a long history of discussion on this topic. I believe the current state-of-the-discussion is that specialization would solve a lot of the same use cases (including your example), and specialization is almost certainly going to stabilize long before any form of negative trait bounds, so that’s why there hasn’t been much chatter on the subject lately.

EDIT: here’s some not-so-light background reading on a few of the many interrelated topics that negative bounds touches on:

2 Likes

Cool, I’m glad to see that this is being worked on. thanks.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.