Is it possible to write impl on both general case and special case?
⚓ Rust 📅 2025-12-07 👤 surdeus 👁️ 3I am making a type wrapper MyType for internal type T, and MyType can deref to T. When doing some related impl for traits.There are three cases.
impl PartialEq for MyTypeimpl PartialEq<ExternalType> for MyTypeimpl PartialEq<MyType> for ExternalType
I have done the first case. And due to foreign trait for non-local type rule, I had to do the third case one by one.
But for second case, apparently impl<A: PartialEq<MyType>> PartialEq<A> for MyType {} conflicts with the first case. Is there a way to make this possible, somehow rule out MyType in A?
2 posts - 2 participants
🏷️ Rust_feed