pub trait TupleZip<T> {
type Output;
fn zip(self, val: T) -> Self::Output;
}
pub trait TupleInsertExact<const POS: usize, T> {
type Output;
fn insert(self, val: T) -> Self::Output;
}
pub trait TupleInsert<T> {
fn insert<const POS: usize>(self, val: T) -> Self::Output
where
Self: TupleInsertExact<POS, T> + Sized,
{
<Self as TupleInsertExact<POS, T>>::insert(self, val)
}
}
pub trait TupleRemoveExact<const POS: usize> {
type Output;
fn remove(self) -> Self::Output;
}
pub trait TupleRemove {
fn remove<const POS: usize>(self) -> Self::Output
where
Self: TupleRemoveExact<POS> + Sized,
{
<Self as TupleRemoveExact<POS>>::remove(self)
}
}
pub trait TupleConcat<T> {
type Output;
fn concat(self, other: T) -> Self::Output;
}
mod __generated {
use paste::paste;
use super::{
TupleConcat, TupleInsert, TupleInsertExact, TupleRemove, TupleRemoveExact, TupleZip,
};
macro_rules! __impl_tuple_zip {
($($ph:ident),+ | $tar:ident) => {
paste! {
impl<$($ph),+, $tar> TupleZip<$tar> for ($($ph,)+) {
type Output = ($($ph),+, $tar);
fn zip(self, val: $tar) -> Self::Output {
let ($([< $ph:lower >],)+) = self;
($([< $ph:lower >]),+, val)
}
}
}
};
}
macro_rules! __impl_tuple_insert {
($($ph:ident),+ | $tar:ident) => {
impl<$($ph),+, $tar> TupleInsert<$tar> for ($($ph,)+) {}
};
}
macro_rules! __impl_tuple_insert_exact {
($($ph:ident),+ | $tar:ident at $index:expr => $($res:ident),+) => {
paste! {
impl<$($ph),+, $tar> TupleInsertExact<$index, $tar> for ($($ph,)+) {
type Output = ($($res,)+);
fn insert(self, val: $tar) -> Self::Output {
let [< $tar:lower >] = val;
let ($([< $ph:lower >],)+) = self;
($([< $res:lower >]),+)
}
}
}
};
}
macro_rules! __impl_tuple_remove {
($($ph:ident),+) => {
impl<$($ph),+> TupleRemove for ($($ph,)+) {}
};
}
macro_rules! __impl_tuple_remove_exact {
($($ph:ident),+ at $index:expr => $($res:ident),+) => {
paste! {
impl<$($ph),+> TupleRemoveExact<$index> for ($($ph,)+) {
type Output = ($($res,)+);
#[allow(unused_variables)]
fn remove(self) -> Self::Output {
let ($([< $ph:lower >],)+) = self;
($([< $res:lower >],)+)
}
}
}
};
}
macro_rules! __impl_tuple_concat {
($($ph:ident),+ with $($tar:ident),+) => {
paste! {
impl<$($ph),+, $($tar),+> TupleConcat<($($tar,)+)> for ($($ph,)+) {
type Output = ($($ph),+, $($tar),+);
fn concat(self, other: ($($tar,)+)) -> Self::Output {
let ($([< $ph:lower >],)+) = self;
let ($([< $tar:lower >],)+) = other;
($([< $ph:lower >]),+, $([< $tar:lower >]),+)
}
}
}
};
}
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/tuple_short_impl.rs"
));
#[cfg(feature = "long-tuple-impl")]
mod __long_tuple_impl {
use paste::paste;
use super::super::{
TupleConcat, TupleInsert, TupleInsertExact, TupleRemove, TupleRemoveExact, TupleZip,
};
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/tuple_long_impl.rs"
));
}
}