|
| 1 | +pub struct Color<T>(pub T); |
| 2 | + |
| 3 | +pub struct Cell<Fg, Bg = Fg> { |
| 4 | + foreground: Color<Fg>, |
| 5 | + background: Color<Bg>, |
| 6 | +} |
| 7 | + |
| 8 | +pub trait Over<Bottom, Output> { |
| 9 | + fn over(self, bottom: Bottom) -> Output; |
| 10 | +} |
| 11 | + |
| 12 | +// Cell: Over<Color, Cell> |
| 13 | +impl<C, Fg, Bg, NewFg, NewBg> Over<Color<C>, Cell<NewFg, NewBg>> for Cell<Fg, Bg> |
| 14 | +where |
| 15 | + Fg: Over<C, NewFg>, |
| 16 | + Bg: Over<C, NewBg>, |
| 17 | +{ |
| 18 | + fn over(self, _: Color<C>) -> Cell<NewFg, NewBg> { |
| 19 | + todo!(); |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +// Cell: Over<Cell, Cell> |
| 24 | +impl<TopFg, TopBg, BottomFg, BottomBg, NewFg, NewBg> |
| 25 | + Over<Cell<BottomFg, BottomBg>, Cell<NewFg, NewBg>> for Cell<TopFg, TopBg> |
| 26 | +where |
| 27 | + Self: Over<Color<BottomBg>, Cell<NewFg, NewBg>>, |
| 28 | +{ |
| 29 | + fn over(self, bottom: Cell<BottomFg, BottomBg>) -> Cell<NewFg, NewBg> { |
| 30 | + self.over(bottom.background); |
| 31 | + todo!(); |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +// Cell: Over<&mut Cell, ()> |
| 36 | +impl<'b, TopFg, TopBg, BottomFg, BottomBg> Over<&'b mut Cell<BottomFg, BottomBg>, ()> |
| 37 | + for Cell<TopFg, TopBg> |
| 38 | +where |
| 39 | + Cell<TopFg, TopBg>: Over<Cell<BottomFg, BottomBg>, Cell<BottomFg, BottomBg>>, |
| 40 | +{ |
| 41 | + fn over(self, _: &'b mut Cell<BottomFg, BottomBg>) { |
| 42 | + todo!(); |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +// &Cell: Over<&mut Cell, ()> |
| 47 | +impl<'t, 'b, TopFg, TopBg, BottomFg, BottomBg> Over<&'b mut Cell<BottomFg, BottomBg>, ()> |
| 48 | + for &'t Cell<TopFg, TopBg> |
| 49 | +where |
| 50 | + Cell<TopFg, TopBg>: Over<Cell<BottomFg, BottomBg>, Cell<BottomFg, BottomBg>>, |
| 51 | +{ |
| 52 | + fn over(self, _: &'b mut Cell<BottomFg, BottomBg>) { |
| 53 | + todo!(); |
| 54 | + } |
| 55 | +} |
0 commit comments