1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
pub struct Here; pub struct There<T>(T); pub trait Count { fn count() -> u32; } impl Count for Here { #[inline] fn count() -> u32 { 0 } } impl<N> Count for There<N> where N: Count, { fn count() -> u32 { N::count() + 1 } }