Consider the following scenario:
- I want to implement a trait
Do
on all the types that implement a traitCanDo
. - Out of the types that
CanDo
, some implement a traitCanDoQuickly
. - I would like
Do
to be implemented in one way for those types thatCanDo
, but notCanDoQuickly
, and in another way for those types thatCanDoQuickly
.
I know that, in Rust, we have no negative trait bounds. My intuition is that we should probably be able to use opt-in built-in to achieve this (although, I did try unsuccessfully).
I am wondering if it is at all possible, no matter the complexity of the code, to achieve what I would like to do on stable Rust. If not, is it a design choice? Is it inherently bad to want to do something like this? It sounds like such a common problem to me that I'd be very surprised to find out it's a deprecated practice.