use crate::{ lenses::{LensOver, LensView}, Optics, OpticsTrait, }; #[derive(Clone, Copy)] pub struct Combination(A, B); impl OpticsTrait for Combination {} impl std::ops::Add> for Optics where A: OpticsTrait, B: OpticsTrait, { type Output = Optics, Optics>>; fn add(self, rhs: Optics) -> Self::Output { Optics(Combination(self, rhs)) } } impl LensView for Combination where A: LensView, B: LensView, { type Field = B::Field; fn view(thing: T) -> Self::Field { B::view(A::view(thing)) } } impl LensOver for Combination where A: LensOver, B: LensOver, { fn over(thing: T, f: F) -> T where F: FnOnce(Self::Field) -> Self::Field, { A::over(thing, |b| B::over(b, f)) } }