use crate::{Lens, LensOver, LensTrait, LensView}; #[derive(Clone, Copy)] pub struct Combination(A, B); impl LensTrait for Combination {} impl std::ops::Add> for Lens where A: LensTrait, B: LensTrait, { 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(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)) } }