use crate::{ lenses::{Lens, LensOver, LensView}, prisms::{Prism, PrismPreview}, traversals::{Traversal, TraversalOver, TraversalTraverse}, }; // lens view impl std::ops::FnOnce<(A,)> for Lens where L: LensView, { type Output = L::Field; extern "rust-call" fn call_once(self, args: (A,)) -> Self::Output { L::view(&self.0, args.0) } } impl std::ops::FnMut<(A,)> for Lens where L: LensView, { extern "rust-call" fn call_mut(&mut self, args: (A,)) -> Self::Output { L::view(&self.0, args.0) } } impl std::ops::Fn<(A,)> for Lens where L: LensView, { extern "rust-call" fn call(&self, args: (A,)) -> Self::Output { L::view(&self.0, args.0) } } // lens over impl std::ops::FnOnce<(A, F)> for Lens where L: LensOver, F: FnOnce(L::Field) -> L::Field, { type Output = A; extern "rust-call" fn call_once(self, args: (A, F)) -> Self::Output { L::over(&self.0, args.0, args.1) } } impl std::ops::FnMut<(A, F)> for Lens where L: LensOver, F: FnOnce(L::Field) -> L::Field, { extern "rust-call" fn call_mut(&mut self, args: (A, F)) -> Self::Output { L::over(&self.0, args.0, args.1) } } impl std::ops::Fn<(A, F)> for Lens where L: LensOver, F: FnOnce(L::Field) -> L::Field, { extern "rust-call" fn call(&self, args: (A, F)) -> Self::Output { L::over(&self.0, args.0, args.1) } } // traversal traverse impl std::ops::FnOnce<(A,)> for Traversal where L: TraversalTraverse, { type Output = Vec; extern "rust-call" fn call_once(self, args: (A,)) -> Self::Output { L::traverse(&self.0, args.0) } } impl std::ops::FnMut<(A,)> for Traversal where L: TraversalTraverse, { extern "rust-call" fn call_mut(&mut self, args: (A,)) -> Self::Output { L::traverse(&self.0, args.0) } } impl std::ops::Fn<(A,)> for Traversal where L: TraversalTraverse, { extern "rust-call" fn call(&self, args: (A,)) -> Self::Output { L::traverse(&self.0, args.0) } } // traversal over impl std::ops::FnOnce<(A, F)> for Traversal where L: TraversalOver, F: FnMut(L::Field) -> L::Field, { type Output = A; extern "rust-call" fn call_once(self, args: (A, F)) -> Self::Output { L::over(&self.0, args.0, args.1) } } impl std::ops::FnMut<(A, F)> for Traversal where L: TraversalOver, F: FnMut(L::Field) -> L::Field, { extern "rust-call" fn call_mut(&mut self, args: (A, F)) -> Self::Output { L::over(&self.0, args.0, args.1) } } impl std::ops::Fn<(A, F)> for Traversal where L: TraversalOver, F: FnMut(L::Field) -> L::Field, { extern "rust-call" fn call(&self, args: (A, F)) -> Self::Output { L::over(&self.0, args.0, args.1) } } // prism preview impl std::ops::FnOnce<(A,)> for Prism where L: PrismPreview, { type Output = Option; extern "rust-call" fn call_once(self, args: (A,)) -> Self::Output { L::preview(&self.0, args.0) } } impl std::ops::FnMut<(A,)> for Prism where L: PrismPreview, { extern "rust-call" fn call_mut(&mut self, args: (A,)) -> Self::Output { L::preview(&self.0, args.0) } } impl std::ops::Fn<(A,)> for Prism where L: PrismPreview, { extern "rust-call" fn call(&self, args: (A,)) -> Self::Output { L::preview(&self.0, args.0) } } // prism over impl std::ops::FnOnce<(A, F)> for Prism where A: Clone, L: PrismPreview, F: FnMut(L::Field) -> L::Field, { type Output = A; extern "rust-call" fn call_once(self, args: (A, F)) -> Self::Output { L::over(&self.0, args.0, args.1) } } impl std::ops::FnMut<(A, F)> for Prism where A: Clone, L: PrismPreview, F: FnMut(L::Field) -> L::Field, { extern "rust-call" fn call_mut(&mut self, args: (A, F)) -> Self::Output { L::over(&self.0, args.0, args.1) } } impl std::ops::Fn<(A, F)> for Prism where A: Clone, L: PrismPreview, F: FnMut(L::Field) -> L::Field, { extern "rust-call" fn call(&self, args: (A, F)) -> Self::Output { L::over(&self.0, args.0, args.1) } }