conflicting implementations of a trait with generics
Writing a generic Repository<T> and trying to impl a trait for two cases, one for T: Serialize and one for T: DeserializeOwned. Compiler says:
error[E0119]: conflicting implementations of trait Store for type Repository<_>:
--> src/repo.rs:44:1
|
44 | impl<T: Serialize> Store for Repository<T> { ... }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ first implementation here
45 | impl<T: DeserializeOwned> Store for Repository<T> { ... }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
Some types satisfy both bounds. How do people usually work around this without specialization?
4 replies