Is there a way to restrict the implementation of a trait to types only, that have implemented another trait?
This implements TraitBar
for everything that implements TraitFoo
:
impl<T: TraitFoo> TraitBar for T {
...
}
That one I'm aware of. What I have in mind is the other way around. A way to tell the compiler to not allow implementation on types that don't have a certrain trait implemented
You can define the trait like this:
trait TraitBar: TraitFoo {
...
}
2 Likes
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.