pub trait Cons {
type Left;
type Right;
}
macro_rules! impl_tuples {
($T:ident) => {
impl<$T> Cons for ($T,) {
type Left = $T;
type Right = ();
}
};
($T:ident, $($Tail:ident),*) => {
impl<$T, $($Tail),*> Cons for ($T, $($Tail),*) {
type Left = $T;
type Right = ($($Tail),*,);
}
impl_tuples!($($Tail),*);
};
}
crate::tuple_list!(impl_tuples);
#[cfg(test)]
mod test {
use static_assertions::{assert_impl_all, assert_not_impl_all};
use super::*;
assert_impl_all!((usize,): Cons<Left = usize, Right = ()>);
assert_impl_all!((usize, usize): Cons<Left = usize, Right = (usize,)>);
assert_impl_all!((usize, usize, usize): Cons<Left = usize, Right = (usize, usize)>);
assert_not_impl_all!((): Cons);
}