type-sets 0.2.0

Sets implemented in the rust type-system
Documentation
use super::*;

/// Type alias for the union of two type sets.
///
/// # Example
///
/// ```rust
/// # use type_sets::*;
/// assert::eq::<Union<(i32,), (i16,)>, (i32, i16)>();
/// ```
pub type Union<T, R> = <T as Extend<R>>::Output;

/// Trait for extending a type set with another type set.
///
/// See [`Union`] for a convenient type alias to compute the union of two type sets.
pub trait Extend<T: ?Sized> {
    type Output: ?Sized;
}

impl<T> Extend<()> for T {
    type Output = T;
}

impl<T, E1> Extend<(E1,)> for T
where
    T: Push,
{
    type Output = <T::Output<E1> as Extend<()>>::Output;
}

impl<T, E1, E2> Extend<(E1, E2)> for T
where
    T: Push<Output<E1>: Push>,
{
    type Output = <T::Output<E1> as Extend<(E2,)>>::Output;
}

impl<T, E1, E2, E3> Extend<(E1, E2, E3)> for T
where
    T: Push<Output<E1>: Push<Output<E2>: Push>>,
{
    type Output = <T::Output<E1> as Extend<(E2, E3)>>::Output;
}

impl<T, E1, E2, E3, E4> Extend<(E1, E2, E3, E4)> for T
where
    T: Push<Output<E1>: Push<Output<E2>: Push<Output<E3>: Push>>>,
{
    type Output = <T::Output<E1> as Extend<(E2, E3, E4)>>::Output;
}

impl<T, E1, E2, E3, E4, E5> Extend<(E1, E2, E3, E4, E5)> for T
where
    T: Push<Output<E1>: Push<Output<E2>: Push<Output<E3>: Push<Output<E4>: Push>>>>,
{
    type Output = <T::Output<E1> as Extend<(E2, E3, E4, E5)>>::Output;
}

impl<T, E1, E2, E3, E4, E5, E6> Extend<(E1, E2, E3, E4, E5, E6)> for T
where
    T: Push<
        Output<E1>: Push<Output<E2>: Push<Output<E3>: Push<Output<E4>: Push<Output<E5>: Push>>>>,
    >,
{
    type Output = <T::Output<E1> as Extend<(E2, E3, E4, E5, E6)>>::Output;
}

impl<T, E1, E2, E3, E4, E5, E6, E7> Extend<(E1, E2, E3, E4, E5, E6, E7)> for T
where
    T: Push<
        Output<E1>: Push<
            Output<E2>: Push<
                Output<E3>: Push<Output<E4>: Push<Output<E5>: Push<Output<E6>: Push>>>,
            >,
        >,
    >,
{
    type Output = <T::Output<E1> as Extend<(E2, E3, E4, E5, E6, E7)>>::Output;
}

impl<T, E1, E2, E3, E4, E5, E6, E7, E8> Extend<(E1, E2, E3, E4, E5, E6, E7, E8)> for T
where
    T: Push<
        Output<E1>: Push<
            Output<E2>: Push<
                Output<E3>: Push<
                    Output<E4>: Push<Output<E5>: Push<Output<E6>: Push<Output<E7>: Push>>>,
                >,
            >,
        >,
    >,
{
    type Output = <T::Output<E1> as Extend<(E2, E3, E4, E5, E6, E7, E8)>>::Output;
}

impl<T, E1, E2, E3, E4, E5, E6, E7, E8, E9> Extend<(E1, E2, E3, E4, E5, E6, E7, E8, E9)> for T
where
    T: Push<
        Output<E1>: Push<
            Output<E2>: Push<
                Output<E3>: Push<
                    Output<E4>: Push<
                        Output<E5>: Push<Output<E6>: Push<Output<E7>: Push<Output<E8>: Push>>>,
                    >,
                >,
            >,
        >,
    >,
{
    type Output = <T::Output<E1> as Extend<(E2, E3, E4, E5, E6, E7, E8, E9)>>::Output;
}

impl<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10> Extend<(E1, E2, E3, E4, E5, E6, E7, E8, E9, E10)>
    for T
where
    T: Push<
        Output<E1>: Push<
            Output<E2>: Push<
                Output<E3>: Push<
                    Output<E4>: Push<
                        Output<E5>: Push<
                            Output<E6>: Push<Output<E7>: Push<Output<E8>: Push<Output<E9>: Push>>>,
                        >,
                    >,
                >,
            >,
        >,
    >,
{
    type Output = <T::Output<E1> as Extend<(E2, E3, E4, E5, E6, E7, E8, E9, E10)>>::Output;
}

impl<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11>
    Extend<(E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11)> for T
where
    T: Push<
        Output<E1>: Push<
            Output<E2>: Push<
                Output<E3>: Push<
                    Output<E4>: Push<
                        Output<E5>: Push<
                            Output<E6>: Push<
                                Output<E7>: Push<
                                    Output<E8>: Push<Output<E9>: Push<Output<E10>: Push>>,
                                >,
                            >,
                        >,
                    >,
                >,
            >,
        >,
    >,
{
    type Output = <T::Output<E1> as Extend<(E2, E3, E4, E5, E6, E7, E8, E9, E10, E11)>>::Output;
}

impl<T, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12>
    Extend<(E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12)> for T
where
    T: Push<
        Output<E1>: Push<
            Output<E2>: Push<
                Output<E3>: Push<
                    Output<E4>: Push<
                        Output<E5>: Push<
                            Output<E6>: Push<
                                Output<E7>: Push<
                                    Output<E8>: Push<
                                        Output<E9>: Push<Output<E10>: Push<Output<E11>: Push>>,
                                    >,
                                >,
                            >,
                        >,
                    >,
                >,
            >,
        >,
    >,
{
    type Output =
        <T::Output<E1> as Extend<(E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12)>>::Output;
}