fn main() { println!("{}", (1, (2, (4, Empty()))).get::>>()); } struct Empty (); trait Cons { type Tail: Cons; fn get_head(&self) -> &T; fn get_tail(&self) -> &Self::Tail; fn get(&self) -> &T where Self: std::marker::Sized { P::get(self) } } impl> Cons for (T, C) { type Tail = C; fn get_head(&self) -> &T { &self.0 } fn get_tail(&self) -> &Self::Tail { &self.1 } } impl Cons for Empty { type Tail = Empty; fn get_head(&self) -> &T { panic!() } fn get_tail(&self) -> &Self::Tail { panic!() } } enum Zero {} trait Peano { fn get>(cons: &C) -> &T; } impl Peano for Zero { fn get>(cons: &C) -> &T { cons.get_head() } } struct Succ(T); impl Peano for Succ

{ fn get>(cons: &C) -> &T { P::get(cons.get_tail()) } }