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