pub trait SetterOptic<'a, PointerBrand: ToDynCloneFn, S: 'a, T: 'a, A: 'a, B: 'a> {
// Required method
fn evaluate(
&self,
pab: <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, A, B>,
) -> <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, S, T>;
}Expand description
A setter optic.
§Type Parameters
'a: The lifetime of the values.PointerBrand: The reference-counted pointer type.S: The source type of the structure.T: The target type of the structure after an update.A: The source type of the focus.B: The target type of the focus after an update.
Required Methods§
Sourcefn 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>
Evaluate the optic with the function profunctor.
§Type Signature
(&self, Fn Pointer A B) -> Fn Pointer S T
§Parameters
&self: The optic instance.pab: The profunctor value to transform.
§Returns
The transformed function profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let s: SetterPrime<RcBrand, (i32, String), i32> =
SetterPrime::new(|(s, f): ((i32, String), Box<dyn Fn(i32) -> i32>)| (f(s.0), s.1));
let f = lift_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2);
let modifier = <SetterPrime<RcBrand, (i32, String), i32> as SetterOptic<
RcBrand,
(i32, String),
(i32, String),
i32,
i32,
>>::evaluate(&s, f);
assert_eq!(modifier((21, "hi".to_string())), (42, "hi".to_string()));Implementors§
impl<'a, PointerBrand, S, A> SetterOptic<'a, PointerBrand, S, S, A, A> for GratePrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a + Clone,
<PointerBrand as RefCountedPointer>::Of<'a, S>: Sized,
§Type Parameters
'a: The lifetime of the values.PointerBrand: The reference-counted pointer type.S: The type of the structure.A: The type of the focus.
impl<'a, PointerBrand, S, T, A, B> SetterOptic<'a, PointerBrand, S, T, A, B> for Grate<'a, PointerBrand, S, T, A, B>where
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a,
B: 'a + Clone,
<PointerBrand as RefCountedPointer>::Of<'a, S>: Sized,
§Type Parameters
'a: The lifetime of the values.PointerBrand: The reference-counted pointer type.S: The source type of the structure.T: The target type of the structure after an update.A: The source type of the focus.B: The target type of the focus after an update.
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: ToDynCloneFn,
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, Q, PointerBrand, S, A> SetterOptic<'a, Q, S, S, A, A> for SetterPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
Q: ToDynCloneFn,
S: 'a,
A: 'a,
§Type Parameters
'a: The lifetime of the values.Q: The pointer brand for the setter.PointerBrand: The type of the structure.S: The type of the focus.A: The pointer brand for the function profunctor.
impl<'a, Q, PointerBrand, S, T, A, B> SetterOptic<'a, Q, S, T, A, B> for Setter<'a, PointerBrand, S, T, A, B>where
PointerBrand: ToDynCloneFn,
Q: ToDynCloneFn,
S: 'a,
T: 'a,
A: 'a,
B: 'a,
§Type Parameters
'a: The lifetime of the values.Q: The pointer brand for the setter.PointerBrand: The source type of the structure.S: The target type of the structure.T: The source type of the focus.A: The target type of the focus.B: The pointer brand for the function profunctor.
impl<'a, Q, PointerBrand, S, T, A, B, F> SetterOptic<'a, Q, S, T, A, B> for Traversal<'a, PointerBrand, S, T, A, B, F>where
PointerBrand: ToDynCloneFn,
Q: ToDynCloneFn,
F: TraversalFunc<'a, S, T, A, B> + Clone + 'a,
S: 'a,
T: 'a,
A: 'a,
B: 'a + Clone,
§Type Parameters
'a: The lifetime of the values.Q: The reference-counted pointer type for the setter brand.PointerBrand: The reference-counted pointer type for the traversal.S: The source type of the structure.T: The target type of the structure after an update.A: The source type of the focus.B: The target type of the focus after an update.F: The type of the traversal function.
impl<'a, Q, PointerBrand, S: 'a, A: 'a> SetterOptic<'a, Q, S, S, A, A> for AffineTraversalPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
Q: ToDynCloneFn,
§Type Parameters
'a: The lifetime of the values.Q: The profunctor type.PointerBrand: The reference-counted pointer type.S: The type of the structure.A: The type of the focus.
impl<'a, Q, PointerBrand, S: 'a, A: 'a> SetterOptic<'a, Q, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
Q: ToDynCloneFn,
§Type Parameters
'a: The lifetime of the values.Q: The reference-counted pointer type for the setter brand.PointerBrand: The reference-counted pointer type for the iso.S: The type of the structure.A: The type of the focus.
impl<'a, Q, PointerBrand, S: 'a, A: 'a> SetterOptic<'a, Q, S, S, A, A> for LensPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
Q: ToDynCloneFn,
§Type Parameters
'a: The lifetime of the values.Q: The reference-counted pointer type for the setter brand.PointerBrand: The reference-counted pointer type for the lens.S: The type of the structure.A: The type of the focus.
impl<'a, Q, PointerBrand, S: 'a, A: 'a> SetterOptic<'a, Q, S, S, A, A> for PrismPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
Q: ToDynCloneFn,
§Type Parameters
'a: The lifetime of the values.Q: The reference-counted pointer type for the setter brand.PointerBrand: The reference-counted pointer type for the prism.S: The type of the structure.A: The type of the focus.
impl<'a, Q, PointerBrand, S: 'a, T: 'a, A: 'a, B: 'a> SetterOptic<'a, Q, S, T, A, B> for AffineTraversal<'a, PointerBrand, S, T, A, B>where
PointerBrand: ToDynCloneFn,
Q: ToDynCloneFn,
§Type Parameters
'a: The lifetime of the values.Q: The profunctor type.PointerBrand: The reference-counted pointer type.S: The source type of the structure.T: The target type of the structure after an update.A: The source type of the focus.B: The target type of the focus after an update.
impl<'a, Q, PointerBrand, S: 'a, T: 'a, A: 'a, B: 'a> SetterOptic<'a, Q, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: ToDynCloneFn,
Q: ToDynCloneFn,
§Type Parameters
'a: The lifetime of the values.Q: The reference-counted pointer type for the setter brand.PointerBrand: The reference-counted pointer type for the iso.S: The source type of the structure.T: The target type of the structure after an update.A: The source type of the focus.B: The target type of the focus after an update.
impl<'a, Q, PointerBrand, S: 'a, T: 'a, A: 'a, B: 'a> SetterOptic<'a, Q, S, T, A, B> for Lens<'a, PointerBrand, S, T, A, B>where
PointerBrand: ToDynCloneFn,
Q: ToDynCloneFn,
§Type Parameters
'a: The lifetime of the values.Q: The reference-counted pointer type for the setter brand.PointerBrand: The reference-counted pointer type for the lens.S: The source type of the structure.T: The target type of the structure after an update.A: The source type of the focus.B: The target type of the focus after an update.
impl<'a, Q, PointerBrand, S: 'a, T: 'a, A: 'a, B: 'a> SetterOptic<'a, Q, S, T, A, B> for Prism<'a, PointerBrand, S, T, A, B>where
PointerBrand: ToDynCloneFn,
Q: ToDynCloneFn,
§Type Parameters
'a: The lifetime of the values.Q: The reference-counted pointer type for the setter brand.PointerBrand: The reference-counted pointer type for the prism.S: The source type of the structure.T: The target type of the structure after an update.A: The source type of the focus.B: The target type of the focus after an update.