use variadics::*; pub trait Boxed: Variadic { type Boxed; fn boxed(self) -> Self::Boxed; } impl Boxed for (Item, Rest) where Rest: Boxed, { type Boxed = var_type!(Box, ...Rest::Boxed); fn boxed(self) -> Self::Boxed { let (item, rest) = self; var_expr!(Box::new(item), ...rest.boxed()) } } impl Boxed for () { type Boxed = (); fn boxed(self) -> Self::Boxed {} } pub trait Refed: Variadic { type Refed<'a> where Self: 'a; fn refed(&self) -> Self::Refed<'_>; } impl Refed for (Item, Rest) where Rest: Refed, { type Refed<'a> = (&'a Item, Rest::Refed<'a>) where Self: 'a; fn refed(&self) -> Self::Refed<'_> { let (item, rest) = self; (item, rest.refed()) } } impl Refed for () { type Refed<'a> = (); fn refed(&self) -> Self::Refed<'_> {} }