Creating a unique set of types in tuple

Hi,
i'm trying to create a unique set of types for example of a Tuple:
e.g.
(usize,usize,usize)-> usize
(usize,u64,usize)-> (usize,u64)
As a starting point a i tried:

pub trait UniqueType {
    type ReducedType;
}

impl<A, B> UniqueType for (A, B)
{
    type ReducedType = Self;
}
impl<A> UniqueType for (A, A)
{
    type ReducedType = A;
}

which doesn't compile due to overlap.
for guarding the different implementations i tried all kinds of unstable features like const expr by making the trait generic over a bool and checking for identical type ids, auto traits with negative impl - they don't work for generic types, specialisation(doesn't work well with associated types) a.s.o but even with these features i couldn't produce a working version even for the must simple case above.
Any hint would be highly appreciated.

What you're asking for is a kind of specialization, because anything that does “if these two types are not equal, then ...” is a kind of specialization. I can't tell you how to do it because I don't write code using the specialization feature, but you definitely can't achieve it without specialization.

This feels like an XY problem. What is the actual engineering problem you are trying to solve that led you down this path? Perhaps there is a better way to do that thing.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.