coproduct/
count.rs

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