pub struct Composed<'a, S, T, M, N, A, B, O1, O2> {
pub first: O1,
pub second: O2,
/* private fields */
}Expand description
This struct represents the composition of two optics, allowing them to be combined into a single optic that applies both transformations.
§Type Parameters
'a: The lifetime of the values.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Fields§
§first: O1The outer optic (applied second).
second: O2The inner optic (applied first).
Implementations§
Source§impl<'a, S, T, M, N, A, B, O1, O2> Composed<'a, S, T, M, N, A, B, O1, O2>
§Type Parameters
'a: The lifetime of the values.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, S, T, M, N, A, B, O1, O2> Composed<'a, S, T, M, N, A, B, O1, O2>
§Type Parameters
'a: The lifetime of the values.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Sourcepub fn new(first: O1, second: O2) -> Self
pub fn new(first: O1, second: O2) -> Self
Create a new composed optic.
§Type Signature
forall S T M N A B O1 O2. (O1, O2) -> Composed S T M N A B O1 O2
§Parameters
first: The outer optic (applied second).second: The inner optic (applied first).
§Returns
A new instance of the type.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let l1: LensPrime<RcBrand, (i32, String), i32> =
LensPrime::from_view_set(|(x, _): (i32, String)| x, |((_, s), x)| (x, s));
let l2: LensPrime<RcBrand, i32, i32> = LensPrime::from_view_set(|x: i32| x, |(_, x)| x);
let composed = Composed::new(l1, l2);
let f = cloneable_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2);
let modifier = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
LensPrime<RcBrand, (i32, String), i32>,
LensPrime<RcBrand, i32, i32>,
> as Optic<RcFnBrand, _, _, _, _>>::evaluate(&composed, f);
assert_eq!(modifier((21, "hi".to_string())), (42, "hi".to_string()));Trait Implementations§
Source§impl<'a, S, T, M, N, A, B, O1, O2> AffineTraversalOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: AffineTraversalOptic<'a, S, T, M, N>,
O2: AffineTraversalOptic<'a, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, S, T, M, N, A, B, O1, O2> AffineTraversalOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: AffineTraversalOptic<'a, S, T, M, N>,
O2: AffineTraversalOptic<'a, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate<P: Strong + Choice>(
&self,
pab: <P as Kind_266801a817966495>::Of<'a, A, B>,
) -> <P as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<P: Strong + Choice>( &self, pab: <P as Kind_266801a817966495>::Of<'a, A, B>, ) -> <P as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall S T M N A B O1 O2 P. (Strong P, Choice P, AffineTraversalOptic O1, AffineTraversalOptic O2) => (&Composed S T M N A B O1 O2, P A B) -> P S T
§Type Parameters
P: The profunctor type.
§Parameters
&self: The composed optic instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let l1: LensPrime<RcBrand, (i32, String), i32> =
LensPrime::from_view_set(|(x, _): (i32, String)| x, |((_, s), x)| (x, s));
let p2: PrismPrime<RcBrand, i32, i32> = PrismPrime::from_option(Some, |x| x);
let composed = Composed::new(l1, p2);
let f = cloneable_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2);
let modifier = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
LensPrime<RcBrand, (i32, String), i32>,
PrismPrime<RcBrand, i32, i32>,
> as AffineTraversalOptic<(i32, String), (i32, String), i32, i32>>::evaluate::<RcFnBrand>(
&composed, f,
);
assert_eq!(modifier((21, "hi".to_string())), (42, "hi".to_string()));Source§impl<'a, S: Clone, T: Clone, M: Clone, N: Clone, A: Clone, B: Clone, O1: Clone, O2: Clone> Clone for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S: Clone, T: Clone, M: Clone, N: Clone, A: Clone, B: Clone, O1: Clone, O2: Clone> Clone for Composed<'a, S, T, M, N, A, B, O1, O2>
Source§impl<'a, S: Debug, T: Debug, M: Debug, N: Debug, A: Debug, B: Debug, O1: Debug, O2: Debug> Debug for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S: Debug, T: Debug, M: Debug, N: Debug, A: Debug, B: Debug, O1: Debug, O2: Debug> Debug for Composed<'a, S, T, M, N, A, B, O1, O2>
Source§impl<'a, S: Default, T: Default, M: Default, N: Default, A: Default, B: Default, O1: Default, O2: Default> Default for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S: Default, T: Default, M: Default, N: Default, A: Default, B: Default, O1: Default, O2: Default> Default for Composed<'a, S, T, M, N, A, B, O1, O2>
Source§impl<'a, S, A, M, O1, O2> FoldOptic<'a, S, A> for Composed<'a, S, S, M, M, A, A, O1, O2>
§Type Parameters
'a: The lifetime of the values.
S: The source type of the structure.
A: The focus type.
M: The intermediate type.
O1: The first optic.
O2: The second optic.
impl<'a, S, A, M, O1, O2> FoldOptic<'a, S, A> for Composed<'a, S, S, M, M, A, A, O1, O2>
§Type Parameters
'a: The lifetime of the values.S: The source type of the structure.A: The focus type.M: The intermediate type.O1: The first optic.O2: The second optic.
Source§fn evaluate<R: 'a + Monoid + Clone + 'static, PointerBrand: UnsizedCoercible + 'static>(
&self,
pab: <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, A, A>,
) -> <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<R: 'a + Monoid + Clone + 'static, PointerBrand: UnsizedCoercible + 'static>( &self, pab: <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, A, A>, ) -> <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall S A M O1 O2 R PointerBrand. (Monoid R, UnsizedCoercible PointerBrand, FoldOptic O1, FoldOptic O2) => (&Composed S A M O1 O2, Forget PointerBrand R A A) -> Forget PointerBrand R S S
§Type Parameters
R: The monoid type.PointerBrand: The reference-counted pointer type.
§Parameters
&self: The composed optic instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::{
Monoid,
optics::*,
},
functions::*,
types::optics::*,
};
let f1: FoldPrime<RcBrand, Vec<i32>, i32, _> = FoldPrime::new(IterableFoldFn(|v: Vec<i32>| v));
let f2: FoldPrime<RcBrand, i32, i32, _> =
FoldPrime::new(IterableFoldFn(|x: i32| std::iter::once(x)));
let composed = Composed::new(f1, f2);
let f = Forget::<RcBrand, String, i32, i32>::new(|x| x.to_string());
let folded = <Composed<
'_,
Vec<i32>,
Vec<i32>,
i32,
i32,
i32,
i32,
FoldPrime<RcBrand, Vec<i32>, i32, _>,
FoldPrime<RcBrand, i32, i32, _>,
> as FoldOptic<Vec<i32>, i32>>::evaluate::<String, RcBrand>(&composed, f);
assert_eq!(folded.run(vec![1, 2, 3]), "123".to_string());Source§impl<'a, S, A, M, O1, O2> GetterOptic<'a, S, A> for Composed<'a, S, S, M, M, A, A, O1, O2>where
O1: GetterOptic<'a, S, M>,
O2: GetterOptic<'a, M, A>,
M: 'a,
A: 'a,
§Type Parameters
'a: The lifetime of the values.
S: The source type of the structure.
A: The focus type.
M: The intermediate type.
O1: The first optic.
O2: The second optic.
impl<'a, S, A, M, O1, O2> GetterOptic<'a, S, A> for Composed<'a, S, S, M, M, A, A, O1, O2>where
O1: GetterOptic<'a, S, M>,
O2: GetterOptic<'a, M, A>,
M: 'a,
A: 'a,
§Type Parameters
'a: The lifetime of the values.S: The source type of the structure.A: The focus type.M: The intermediate type.O1: The first optic.O2: The second optic.
Source§fn evaluate<R: 'a + 'static, PointerBrand: UnsizedCoercible + 'static>(
&self,
pab: <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, A, A>,
) -> <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<R: 'a + 'static, PointerBrand: UnsizedCoercible + 'static>( &self, pab: <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, A, A>, ) -> <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall S A M O1 O2 R PointerBrand. (UnsizedCoercible PointerBrand, GetterOptic O1, GetterOptic O2) => (&Composed S A M O1 O2, Forget PointerBrand R A A) -> Forget PointerBrand R S S
§Type Parameters
R: The return type of the forget profunctor.PointerBrand: The reference-counted pointer type.
§Parameters
&self: The composed optic instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let g1: GetterPrime<RcBrand, (i32, String), i32> = GetterPrime::new(|(x, _)| x);
let g2: GetterPrime<RcBrand, i32, i32> = GetterPrime::new(|x| x);
let composed = Composed::new(g1, g2);
let f = Forget::<RcBrand, i32, i32, i32>::new(|x| x);
let folded = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
GetterPrime<RcBrand, (i32, String), i32>,
GetterPrime<RcBrand, i32, i32>,
> as GetterOptic<(i32, String), i32>>::evaluate::<i32, RcBrand>(&composed, f);
assert_eq!(folded.run((42, "hi".to_string())), 42);Source§impl<'a, FunctionBrand: CloneableFn, S, T, M, N, A, B, O1, O2> GrateOptic<'a, FunctionBrand, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: GrateOptic<'a, FunctionBrand, S, T, M, N>,
O2: GrateOptic<'a, FunctionBrand, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.
FunctionBrand: The cloneable function brand used by the profunctor’s Closed instance.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, FunctionBrand: CloneableFn, S, T, M, N, A, B, O1, O2> GrateOptic<'a, FunctionBrand, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: GrateOptic<'a, FunctionBrand, S, T, M, N>,
O2: GrateOptic<'a, FunctionBrand, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.FunctionBrand: The cloneable function brand used by the profunctor’sClosedinstance.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate<P: Closed<FunctionBrand>>(
&self,
pab: <P as Kind_266801a817966495>::Of<'a, A, B>,
) -> <P as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<P: Closed<FunctionBrand>>( &self, pab: <P as Kind_266801a817966495>::Of<'a, A, B>, ) -> <P as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall S T M N A B O1 O2 P. (Closed P, GrateOptic O1, GrateOptic O2) => (&Composed FunctionBrand S T M N A B O1 O2, P A B) -> P S T
§Type Parameters
P: The profunctor type.
§Parameters
&self: The composed optic instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
// Composition works with lenses too
let l1: LensPrime<RcBrand, (i32, String), i32> =
LensPrime::from_view_set(|(x, _)| x, |((_, s), x)| (x, s));
let l2: LensPrime<RcBrand, i32, i32> = LensPrime::from_view_set(|x| x, |(_, x)| x);
let composed = Composed::new(l1, l2);
let f = cloneable_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2);
let modifier = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
LensPrime<RcBrand, (i32, String), i32>,
LensPrime<RcBrand, i32, i32>,
> as Optic<RcFnBrand, _, _, _, _>>::evaluate(&composed, f);
assert_eq!(modifier((21, "test".to_string())), (42, "test".to_string()));Source§impl<'a, S: Hash, T: Hash, M: Hash, N: Hash, A: Hash, B: Hash, O1: Hash, O2: Hash> Hash for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S: Hash, T: Hash, M: Hash, N: Hash, A: Hash, B: Hash, O1: Hash, O2: Hash> Hash for Composed<'a, S, T, M, N, A, B, O1, O2>
Source§impl<'a, I: 'a, S: 'a, A: 'a, M: 'a, O1, O2> IndexedFoldOptic<'a, I, S, A> for Composed<'a, S, S, M, M, A, A, O1, O2>where
O1: FoldOptic<'a, S, M>,
O2: IndexedFoldOptic<'a, I, M, A>,
§Type Parameters
'a: The lifetime of the values.
I: The index type.
S: The source type of the structure.
A: The focus type.
M: The intermediate type.
O1: The first optic.
O2: The second optic.
impl<'a, I: 'a, S: 'a, A: 'a, M: 'a, O1, O2> IndexedFoldOptic<'a, I, S, A> for Composed<'a, S, S, M, M, A, A, O1, O2>where
O1: FoldOptic<'a, S, M>,
O2: IndexedFoldOptic<'a, I, M, A>,
§Type Parameters
'a: The lifetime of the values.I: The index type.S: The source type of the structure.A: The focus type.M: The intermediate type.O1: The first optic.O2: The second optic.
Source§fn evaluate<R: 'a + Monoid + Clone + 'static, PointerBrand: UnsizedCoercible + 'static>(
&self,
pab: Indexed<'a, ForgetBrand<PointerBrand, R>, I, A, A>,
) -> <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<R: 'a + Monoid + Clone + 'static, PointerBrand: UnsizedCoercible + 'static>( &self, pab: Indexed<'a, ForgetBrand<PointerBrand, R>, I, A, A>, ) -> <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall I S A M O1 O2 R PointerBrand. (Monoid R, UnsizedCoercible PointerBrand, FoldOptic O1, IndexedFoldOptic O2) => (&Composed I S A M O1 O2, crate (Forget PointerBrand R) I A A) -> Forget PointerBrand R S S
§Type Parameters
R: The monoid type.PointerBrand: The reference-counted pointer type.
§Parameters
&self: The composed optic instance.pab: The indexed profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let l1: GetterPrime<RcBrand, (i32, String), i32> = GetterPrime::new(|(x, _)| x);
let l2: IndexedGetterPrime<RcBrand, usize, i32, i32> = IndexedGetterPrime::new(|x| (0, x));
let composed = Composed::new(l1, l2);
let f = Forget::<RcBrand, String, (usize, i32), i32>::new(|(i, x)| format!("{}:{}", i, x));
let folded = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
GetterPrime<RcBrand, (i32, String), i32>,
IndexedGetterPrime<RcBrand, usize, i32, i32>,
> as IndexedFoldOptic<usize, (i32, String), i32>>::evaluate::<String, RcBrand>(
&composed,
Indexed::new(f),
);
assert_eq!(folded.run((42, "hi".to_string())), "0:42");Source§impl<'a, I: 'a, S: 'a, A: 'a, M: 'a, O1, O2> IndexedGetterOptic<'a, I, S, A> for Composed<'a, S, S, M, M, A, A, O1, O2>where
O1: GetterOptic<'a, S, M>,
O2: IndexedGetterOptic<'a, I, M, A>,
§Type Parameters
'a: The lifetime of the values.
I: The index type.
S: The source type of the structure.
A: The focus type.
M: The intermediate type.
O1: The first optic.
O2: The second optic.
impl<'a, I: 'a, S: 'a, A: 'a, M: 'a, O1, O2> IndexedGetterOptic<'a, I, S, A> for Composed<'a, S, S, M, M, A, A, O1, O2>where
O1: GetterOptic<'a, S, M>,
O2: IndexedGetterOptic<'a, I, M, A>,
§Type Parameters
'a: The lifetime of the values.I: The index type.S: The source type of the structure.A: The focus type.M: The intermediate type.O1: The first optic.O2: The second optic.
Source§fn evaluate<R: 'a + 'static, PointerBrand: UnsizedCoercible + 'static>(
&self,
pab: Indexed<'a, ForgetBrand<PointerBrand, R>, I, A, A>,
) -> <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<R: 'a + 'static, PointerBrand: UnsizedCoercible + 'static>( &self, pab: Indexed<'a, ForgetBrand<PointerBrand, R>, I, A, A>, ) -> <ForgetBrand<PointerBrand, R> as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall I S A M O1 O2 R PointerBrand. (UnsizedCoercible PointerBrand, GetterOptic O1, IndexedGetterOptic O2) => (&Composed I S A M O1 O2, crate (Forget PointerBrand R) I A A) -> Forget PointerBrand R S S
§Type Parameters
R: The return type of the forget profunctor.PointerBrand: The reference-counted pointer type.
§Parameters
&self: The composed optic instance.pab: The indexed profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let l1: GetterPrime<RcBrand, (i32, String), i32> = GetterPrime::new(|(x, _)| x);
let l2: IndexedGetterPrime<RcBrand, usize, i32, i32> = IndexedGetterPrime::new(|x| (0, x));
let composed = Composed::new(l1, l2);
let f = Forget::<RcBrand, (usize, i32), (usize, i32), i32>::new(|(i, x)| (i, x));
let folded = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
GetterPrime<RcBrand, (i32, String), i32>,
IndexedGetterPrime<RcBrand, usize, i32, i32>,
> as IndexedGetterOptic<usize, (i32, String), i32>>::evaluate::<(usize, i32), RcBrand>(
&composed,
Indexed::new(f),
);
assert_eq!(folded.run((42, "hi".to_string())), (0, 42));Source§impl<'a, I: 'a, S: 'a, T: 'a, M: 'a, N: 'a, A: 'a, B: 'a, O1, O2> IndexedLensOptic<'a, I, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: LensOptic<'a, S, T, M, N>,
O2: IndexedLensOptic<'a, I, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.
I: The index type.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, I: 'a, S: 'a, T: 'a, M: 'a, N: 'a, A: 'a, B: 'a, O1, O2> IndexedLensOptic<'a, I, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: LensOptic<'a, S, T, M, N>,
O2: IndexedLensOptic<'a, I, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.I: The index type.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate<P: Strong>(
&self,
pab: Indexed<'a, P, I, A, B>,
) -> <P as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<P: Strong>( &self, pab: Indexed<'a, P, I, A, B>, ) -> <P as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall I S T M N A B O1 O2 P. (Strong P, LensOptic O1, IndexedLensOptic O2) => (&Composed I S T M N A B O1 O2, crate P I A B) -> P S T
§Type Parameters
P: The profunctor type.
§Parameters
&self: The composed optic instance.pab: The indexed profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let l1: LensPrime<RcBrand, (i32, String), i32> =
LensPrime::from_view_set(|(x, _)| x, |((_, s), x)| (x, s));
let l2: IndexedLensPrime<RcBrand, usize, i32, i32> =
IndexedLensPrime::from_iview_set(|x| (0, x), |(_, x)| x);
let composed = Composed::new(l1, l2);
let f = |(i, x): (usize, i32)| x + (i as i32);
let indexed = Indexed::<RcFnBrand, usize, i32, i32>::new(std::rc::Rc::new(f));
let modifier = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
LensPrime<RcBrand, (i32, String), i32>,
IndexedLensPrime<RcBrand, usize, i32, i32>,
> as IndexedLensOptic<usize, (i32, String), (i32, String), i32, i32>>::evaluate::<RcFnBrand>(
&composed, indexed,
);
assert_eq!(modifier((21, "hi".to_string())), (21, "hi".to_string()));Source§impl<'a, PointerBrand, I: 'a, S: 'a, T: 'a, M: 'a, N: 'a, A: 'a, B: 'a, O1, O2> IndexedSetterOptic<'a, PointerBrand, I, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
PointerBrand: UnsizedCoercible,
O1: SetterOptic<'a, PointerBrand, S, T, M, N>,
O2: IndexedSetterOptic<'a, PointerBrand, I, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.
PointerBrand: The reference-counted pointer type for the Setter brand.
I: The index type.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, PointerBrand, I: 'a, S: 'a, T: 'a, M: 'a, N: 'a, A: 'a, B: 'a, O1, O2> IndexedSetterOptic<'a, PointerBrand, I, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
PointerBrand: UnsizedCoercible,
O1: SetterOptic<'a, PointerBrand, S, T, M, N>,
O2: IndexedSetterOptic<'a, PointerBrand, I, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.PointerBrand: The reference-counted pointer type for the Setter brand.I: The index type.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate(
&self,
pab: Indexed<'a, FnBrand<PointerBrand>, I, A, B>,
) -> <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate( &self, pab: Indexed<'a, FnBrand<PointerBrand>, I, A, B>, ) -> <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall PointerBrand I S T M N A B O1 O2. (UnsizedCoercible PointerBrand, SetterOptic O1, IndexedSetterOptic O2) => (&Composed PointerBrand I S T M N A B O1 O2, crate (Fn PointerBrand) I A B) -> Fn PointerBrand S T
§Parameters
&self: The composed optic instance.pab: The indexed profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let l1: LensPrime<RcBrand, (i32, String), i32> =
LensPrime::from_view_set(|(x, _)| x, |((_, s), x)| (x, s));
let l2: IndexedLensPrime<RcBrand, usize, i32, i32> =
IndexedLensPrime::from_iview_set(|x| (0, x), |(_, x)| x);
let composed = Composed::new(l1, l2);
let f = |(i, x): (usize, i32)| x + (i as i32);
let indexed = Indexed::<RcFnBrand, usize, i32, i32>::new(std::rc::Rc::new(f));
let modifier = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
LensPrime<RcBrand, (i32, String), i32>,
IndexedLensPrime<RcBrand, usize, i32, i32>,
> as IndexedSetterOptic<RcBrand, usize, (i32, String), (i32, String), i32, i32>>::evaluate(
&composed, indexed,
);
assert_eq!(modifier((21, "hi".to_string())), (21, "hi".to_string()));Source§impl<'a, I: 'a, S: 'a, T: 'a, M: 'a, N: 'a, A: 'a, B: 'a, O1, O2> IndexedTraversalOptic<'a, I, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: TraversalOptic<'a, S, T, M, N>,
O2: IndexedTraversalOptic<'a, I, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.
I: The index type.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, I: 'a, S: 'a, T: 'a, M: 'a, N: 'a, A: 'a, B: 'a, O1, O2> IndexedTraversalOptic<'a, I, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: TraversalOptic<'a, S, T, M, N>,
O2: IndexedTraversalOptic<'a, I, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.I: The index type.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate<P: Wander>(
&self,
pab: Indexed<'a, P, I, A, B>,
) -> <P as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<P: Wander>( &self, pab: Indexed<'a, P, I, A, B>, ) -> <P as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall I S T M N A B O1 O2 P. (Wander P, TraversalOptic O1, IndexedTraversalOptic O2) => (&Composed I S T M N A B O1 O2, crate P I A B) -> P S T
§Type Parameters
P: The profunctor type.
§Parameters
&self: The composed optic instance.pab: The indexed profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let l1: LensPrime<RcBrand, (i32, String), i32> =
LensPrime::from_view_set(|(x, _)| x, |((_, s), x)| (x, s));
let l2: IndexedLensPrime<RcBrand, usize, i32, i32> =
IndexedLensPrime::from_iview_set(|x| (0, x), |(_, x)| x);
let composed = Composed::new(l1, l2);
let f = |(i, x): (usize, i32)| x + (i as i32);
let indexed = Indexed::<RcFnBrand, usize, i32, i32>::new(std::rc::Rc::new(f));
let modifier = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
LensPrime<RcBrand, (i32, String), i32>,
IndexedLensPrime<RcBrand, usize, i32, i32>,
> as IndexedTraversalOptic<usize, (i32, String), (i32, String), i32, i32>>::evaluate::<RcFnBrand>(
&composed, indexed,
);
assert_eq!(modifier((21, "hi".to_string())), (21, "hi".to_string()));Source§impl<'a, S, T, M, N, A, B, O1, O2> IsoOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>
§Type Parameters
'a: The lifetime of the values.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, S, T, M, N, A, B, O1, O2> IsoOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>
§Type Parameters
'a: The lifetime of the values.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate<P: Profunctor + 'static>(
&self,
pab: <P as Kind_266801a817966495>::Of<'a, A, B>,
) -> <P as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<P: Profunctor + 'static>( &self, pab: <P as Kind_266801a817966495>::Of<'a, A, B>, ) -> <P as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall S T M N A B O1 O2 P. (Profunctor P, IsoOptic O1, IsoOptic O2) => (&Composed S T M N A B O1 O2, P A B) -> P S T
§Type Parameters
P: The profunctor type.
§Parameters
&self: The composed optic instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso1: IsoPrime<RcBrand, i32, i32> = IsoPrime::new(|x| x, |x| x);
let iso2: IsoPrime<RcBrand, i32, i32> = IsoPrime::new(|x| x, |x| x);
let composed = Composed::new(iso1, iso2);
let f = cloneable_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2);
let modifier = <Composed<
'_,
i32,
i32,
i32,
i32,
i32,
i32,
IsoPrime<RcBrand, i32, i32>,
IsoPrime<RcBrand, i32, i32>,
> as IsoOptic<i32, i32, i32, i32>>::evaluate::<RcFnBrand>(&composed, f);
assert_eq!(modifier(21), 42);Source§impl<'a, S, T, M, N, A, B, O1, O2> LensOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>
§Type Parameters
'a: The lifetime of the values.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, S, T, M, N, A, B, O1, O2> LensOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>
§Type Parameters
'a: The lifetime of the values.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate<P: Strong>(
&self,
pab: <P as Kind_266801a817966495>::Of<'a, A, B>,
) -> <P as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<P: Strong>( &self, pab: <P as Kind_266801a817966495>::Of<'a, A, B>, ) -> <P as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall S T M N A B O1 O2 P. (Strong P, LensOptic O1, LensOptic O2) => (&Composed S T M N A B O1 O2, P A B) -> P S T
§Type Parameters
P: The profunctor type.
§Parameters
&self: The composed optic instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let l1: LensPrime<RcBrand, (i32, String), i32> =
LensPrime::from_view_set(|(x, _)| x, |((_, s), x)| (x, s));
let l2: LensPrime<RcBrand, i32, i32> = LensPrime::from_view_set(|x| x, |(_, x)| x);
let composed = Composed::new(l1, l2);
let f = cloneable_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2);
let modifier = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
LensPrime<RcBrand, (i32, String), i32>,
LensPrime<RcBrand, i32, i32>,
> as LensOptic<(i32, String), (i32, String), i32, i32>>::evaluate::<RcFnBrand>(
&composed, f
);
assert_eq!(modifier((21, "hi".to_string())), (42, "hi".to_string()));Source§impl<'a, P, S: 'a, T: 'a, M: 'a, N: 'a, A: 'a, B: 'a, O1, O2> Optic<'a, P, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>
§Type Parameters
'a: The lifetime of the values.
P: The profunctor type.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, P, S: 'a, T: 'a, M: 'a, N: 'a, A: 'a, B: 'a, O1, O2> Optic<'a, P, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>
§Type Parameters
'a: The lifetime of the values.P: The profunctor type.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate(
&self,
pab: <P as Kind_266801a817966495>::Of<'a, A, B>,
) -> <P as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate( &self, pab: <P as Kind_266801a817966495>::Of<'a, A, B>, ) -> <P as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall P S T M N A B O1 O2. (Profunctor P, Optic O1, Optic O2) => (&Composed P S T M N A B O1 O2, P A B) -> P S T
§Parameters
&self: The composed optic instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let l1: LensPrime<RcBrand, (i32, String), i32> =
LensPrime::from_view_set(|(x, _): (i32, String)| x, |((_, s), x)| (x, s));
let l2: LensPrime<RcBrand, i32, i32> = LensPrime::from_view_set(|x: i32| x, |(_, x)| x);
let composed = Composed::new(l1, l2);
let f = cloneable_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2);
let modifier = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
LensPrime<RcBrand, (i32, String), i32>,
LensPrime<RcBrand, i32, i32>,
> as Optic<RcFnBrand, _, _, _, _>>::evaluate(&composed, f);
assert_eq!(modifier((21, "hi".to_string())), (42, "hi".to_string()));Source§impl<'a, S: Ord, T: Ord, M: Ord, N: Ord, A: Ord, B: Ord, O1: Ord, O2: Ord> Ord for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S: Ord, T: Ord, M: Ord, N: Ord, A: Ord, B: Ord, O1: Ord, O2: Ord> Ord for Composed<'a, S, T, M, N, A, B, O1, O2>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'a, S: PartialEq, T: PartialEq, M: PartialEq, N: PartialEq, A: PartialEq, B: PartialEq, O1: PartialEq, O2: PartialEq> PartialEq for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S: PartialEq, T: PartialEq, M: PartialEq, N: PartialEq, A: PartialEq, B: PartialEq, O1: PartialEq, O2: PartialEq> PartialEq for Composed<'a, S, T, M, N, A, B, O1, O2>
Source§impl<'a, S: PartialOrd, T: PartialOrd, M: PartialOrd, N: PartialOrd, A: PartialOrd, B: PartialOrd, O1: PartialOrd, O2: PartialOrd> PartialOrd for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S: PartialOrd, T: PartialOrd, M: PartialOrd, N: PartialOrd, A: PartialOrd, B: PartialOrd, O1: PartialOrd, O2: PartialOrd> PartialOrd for Composed<'a, S, T, M, N, A, B, O1, O2>
Source§impl<'a, S, T, M, N, A, B, O1, O2> PrismOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: PrismOptic<'a, S, T, M, N>,
O2: PrismOptic<'a, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, S, T, M, N, A, B, O1, O2> PrismOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: PrismOptic<'a, S, T, M, N>,
O2: PrismOptic<'a, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate<P: Choice>(
&self,
pab: <P as Kind_266801a817966495>::Of<'a, A, B>,
) -> <P as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<P: Choice>( &self, pab: <P as Kind_266801a817966495>::Of<'a, A, B>, ) -> <P as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall S T M N A B O1 O2 P. (Choice P, PrismOptic O1, PrismOptic O2) => (&Composed S T M N A B O1 O2, P A B) -> P S T
§Type Parameters
P: The profunctor type.
§Parameters
&self: The composed optic instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let p1: PrismPrime<RcBrand, Option<i32>, i32> = PrismPrime::from_option(|o| o, Some);
let p2: PrismPrime<RcBrand, i32, i32> = PrismPrime::from_option(Some, |x| x);
let composed = Composed::new(p1, p2);
let f = cloneable_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2);
let modifier =
<Composed<
'_,
Option<i32>,
Option<i32>,
i32,
i32,
i32,
i32,
PrismPrime<RcBrand, Option<i32>, i32>,
PrismPrime<RcBrand, i32, i32>,
> as PrismOptic<Option<i32>, Option<i32>, i32, i32>>::evaluate::<RcFnBrand>(&composed, f);
assert_eq!(modifier(Some(21)), Some(42));Source§impl<'a, S, T, M, N, A, B, O1, O2> ReviewOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: ReviewOptic<'a, S, T, M, N>,
O2: ReviewOptic<'a, M, N, A, B>,
M: 'a,
N: 'a,
§Type Parameters
'a: The lifetime of the values.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, S, T, M, N, A, B, O1, O2> ReviewOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: ReviewOptic<'a, S, T, M, N>,
O2: ReviewOptic<'a, M, N, A, B>,
M: 'a,
N: 'a,
§Type Parameters
'a: The lifetime of the values.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate(
&self,
pab: <TaggedBrand as Kind_266801a817966495>::Of<'a, A, B>,
) -> <TaggedBrand as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate( &self, pab: <TaggedBrand as Kind_266801a817966495>::Of<'a, A, B>, ) -> <TaggedBrand as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall S T M N A B O1 O2. (ReviewOptic O1, ReviewOptic O2) => (&Composed S T M N A B O1 O2, Tagged A B) -> Tagged S T
§Parameters
&self: The composed optic instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let r1: ReviewPrime<RcBrand, Option<i32>, i32> = ReviewPrime::new(Some);
let r2: ReviewPrime<RcBrand, i32, i32> = ReviewPrime::new(|x| x);
let composed = Composed::new(r1, r2);
let f = Tagged::new(21);
let reviewed = <Composed<
'_,
Option<i32>,
Option<i32>,
i32,
i32,
i32,
i32,
ReviewPrime<RcBrand, Option<i32>, i32>,
ReviewPrime<RcBrand, i32, i32>,
> as ReviewOptic<Option<i32>, Option<i32>, i32, i32>>::evaluate(&composed, f);
assert_eq!(reviewed.0, Some(21));Source§impl<'a, PointerBrand, S, T, M, N, A, B, O1, O2> SetterOptic<'a, PointerBrand, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
PointerBrand: UnsizedCoercible,
O1: SetterOptic<'a, PointerBrand, S, T, M, N>,
O2: SetterOptic<'a, PointerBrand, M, N, A, B>,
M: 'a,
N: 'a,
§Type Parameters
'a: The lifetime of the values.
PointerBrand: The reference-counted pointer type for the Setter brand.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, PointerBrand, S, T, M, N, A, B, O1, O2> SetterOptic<'a, PointerBrand, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
PointerBrand: UnsizedCoercible,
O1: SetterOptic<'a, PointerBrand, S, T, M, N>,
O2: SetterOptic<'a, PointerBrand, M, N, A, B>,
M: 'a,
N: 'a,
§Type Parameters
'a: The lifetime of the values.PointerBrand: The reference-counted pointer type for the Setter brand.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate(
&self,
pab: <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, A, B>,
) -> <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate( &self, pab: <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, A, B>, ) -> <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall PointerBrand S T M N A B O1 O2. (UnsizedCoercible PointerBrand, SetterOptic O1, SetterOptic O2) => (&Composed PointerBrand S T M N A B O1 O2, Fn PointerBrand A B) -> Fn PointerBrand S T
§Parameters
&self: The composed optic instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let s1: SetterPrime<RcBrand, (i32, String), i32> =
SetterPrime::new(|(s, f): ((i32, String), Box<dyn Fn(i32) -> i32>)| (f(s.0), s.1));
let s2: SetterPrime<RcBrand, i32, i32> =
SetterPrime::new(|(s, f): (i32, Box<dyn Fn(i32) -> i32>)| f(s));
let composed = Composed::new(s1, s2);
let f = cloneable_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2);
let modifier =
<Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
SetterPrime<RcBrand, (i32, String), i32>,
SetterPrime<RcBrand, i32, i32>,
> as SetterOptic<RcBrand, (i32, String), (i32, String), i32, i32>>::evaluate(&composed, f);
assert_eq!(modifier((21, "hi".to_string())), (42, "hi".to_string()));Source§impl<'a, S, T, M, N, A, B, O1, O2> TraversalOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: TraversalOptic<'a, S, T, M, N>,
O2: TraversalOptic<'a, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.
S: The source type of the outer structure.
T: The target type of the outer structure.
M: The source type of the intermediate structure.
N: The target type of the intermediate structure.
A: The source type of the focus.
B: The target type of the focus.
O1: The first optic.
O2: The second optic.
impl<'a, S, T, M, N, A, B, O1, O2> TraversalOptic<'a, S, T, A, B> for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: TraversalOptic<'a, S, T, M, N>,
O2: TraversalOptic<'a, M, N, A, B>,
§Type Parameters
'a: The lifetime of the values.S: The source type of the outer structure.T: The target type of the outer structure.M: The source type of the intermediate structure.N: The target type of the intermediate structure.A: The source type of the focus.B: The target type of the focus.O1: The first optic.O2: The second optic.
Source§fn evaluate<P: Wander>(
&self,
pab: <P as Kind_266801a817966495>::Of<'a, A, B>,
) -> <P as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<P: Wander>( &self, pab: <P as Kind_266801a817966495>::Of<'a, A, B>, ) -> <P as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall S T M N A B O1 O2 P. (Wander P, TraversalOptic O1, TraversalOptic O2) => (&Composed S T M N A B O1 O2, P A B) -> P S T
§Type Parameters
P: The profunctor type.
§Parameters
&self: The composed optic instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
// Composition combines two optics
let l1: LensPrime<RcBrand, (i32, String), i32> =
LensPrime::from_view_set(|(x, _)| x, |((_, s), x)| (x, s));
let l2: LensPrime<RcBrand, i32, i32> = LensPrime::from_view_set(|x| x, |(_, x)| x);
let composed = Composed::new(l1, l2);
let f = cloneable_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2);
let modifier = <Composed<
'_,
(i32, String),
(i32, String),
i32,
i32,
i32,
i32,
LensPrime<RcBrand, (i32, String), i32>,
LensPrime<RcBrand, i32, i32>,
> as Optic<RcFnBrand, _, _, _, _>>::evaluate(&composed, f);
assert_eq!(modifier((21, "hi".to_string())), (42, "hi".to_string()));impl<'a, S: Copy, T: Copy, M: Copy, N: Copy, A: Copy, B: Copy, O1: Copy, O2: Copy> Copy for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S: Eq, T: Eq, M: Eq, N: Eq, A: Eq, B: Eq, O1: Eq, O2: Eq> Eq for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S, T, M, N, A, B, O1, O2> StructuralPartialEq for Composed<'a, S, T, M, N, A, B, O1, O2>
Auto Trait Implementations§
impl<'a, S, T, M, N, A, B, O1, O2> Freeze for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S, T, M, N, A, B, O1, O2> RefUnwindSafe for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: RefUnwindSafe,
O2: RefUnwindSafe,
S: RefUnwindSafe,
T: RefUnwindSafe,
M: RefUnwindSafe,
N: RefUnwindSafe,
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<'a, S, T, M, N, A, B, O1, O2> Send for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S, T, M, N, A, B, O1, O2> Sync for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S, T, M, N, A, B, O1, O2> Unpin for Composed<'a, S, T, M, N, A, B, O1, O2>
impl<'a, S, T, M, N, A, B, O1, O2> UnsafeUnpin for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: UnsafeUnpin,
O2: UnsafeUnpin,
impl<'a, S, T, M, N, A, B, O1, O2> UnwindSafe for Composed<'a, S, T, M, N, A, B, O1, O2>where
O1: UnwindSafe,
O2: UnwindSafe,
S: RefUnwindSafe,
T: RefUnwindSafe,
M: RefUnwindSafe,
N: RefUnwindSafe,
A: RefUnwindSafe,
B: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more