use derive_bounded::{Clone, Debug, PartialEq}; trait Associate { type A: PartialEq + Clone + std::fmt::Debug; type B: PartialEq + Clone + std::fmt::Debug; type C: PartialEq + Clone + std::fmt::Debug; } #[derive(std::fmt::Debug)] struct Holder; impl Associate for Holder { type A = usize; type B = String; type C = u32; } #[derive(Clone, PartialEq, Debug)] #[bounded_to(T::B, T::C)] struct A { a: T::A, b: B, } #[derive(Clone, PartialEq, Debug)] #[bounded_to(T::C)] struct B { b: T::B, c: C, } #[derive(Clone, PartialEq, Debug)] #[bounded_to(T::C)] struct C { c: T::C, } #[derive(Clone, PartialEq, Debug)] #[bounded_to(T::C)] struct C2 where T: Associate, { c: T::C, v: V, b: Blah, } #[derive(Clone, PartialEq, Debug)] #[bounded_to(T::A, T::B)] enum E { A, B(T::A, T::B), C { a: T::A, b: T::C }, } #[test] fn debug() { let c = C { c: 42 }; let a = A:: { a: 42, b: B { b: "Ok".to_owned(), c: C { c: 42 }, }, }; assert_eq!(c, a.b.c); dbg!(&a); dbg!(&a.b); dbg!(&a.b.c); }