use typle::typle; pub struct Something {} pub trait IsUseful { type State: IsUseful; } pub trait UsefulTrait { type UsefulType: IsUseful; const SIZE: usize; #[allow(dead_code)] fn display(&self) -> String; } #[typle(Tuple for 1..=3)] impl UsefulTrait for T where T<_>: UsefulTrait + std::fmt::Display, typle_bound!(i in 1.. => T<{i}>::UsefulType):IsUseful< typle_fold!( T<0>::UsefulType; j in 1..i => |Inner| ::UsefulType as IsUseful>::State ), >, { type UsefulType = typle_fold!( T<0>::UsefulType; j in 1.. => |Inner| ::UsefulType as IsUseful>::State ); const SIZE: usize = typle_fold!(0; i in .. => |total| total + T::<{i}>::SIZE); fn display(&self) -> String { typle_fold!( "[".to_string() + &self[[0]].to_string(); i in 1.. => |s| s + "," + &self[[i]].to_string() ) + "]" } }