Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: 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.
1 post - 1 participant
🏷️ Rust_feed