use std::*;
trait Unique<T> {
fn unique(self) -> collections::HashSet<T>;
}
impl<T> Unique<T> for T {
fn unique(self) -> collections::HashSet<T> {
iter::once(self).collect()
}
}
impl<T, A: Unique<T>, B: Unique<T>> Unique<T> for (A, B) {
fn unique(self) -> collections::HashSet<T> {
self.0.unique().into_iter().chain(self.1.unique()).collect()
}
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0119]: conflicting implementations of trait `Unique<(_, _)>` for type `(_, _)`
--> src/lib.rs:10:1
|
5 | impl<T> Unique<T> for T {
| ----------------------- first implementation here
...
10 | impl<T, A: Unique<T>, B: Unique<T>> Unique<T> for (A, B) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_, _)`
For more information about this error, try `rustc --explain E0119`.
error: could not compile `playground` (lib) due to previous error
I don't see how conflicting implementations arise. Type (A, B) only implements Unique<(A, B)> once (line 5), because there's no way both A and B could implement Unique<(A, B)>