pub struct IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a,{ /* private fields */ }Expand description
Implementations§
Source§impl<'a, PointerBrand, S: 'a, A: 'a> IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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: 'a, A: 'a> IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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.
Sourcepub fn new(from: impl 'a + Fn(S) -> A, to: impl 'a + Fn(A) -> S) -> Self
pub fn new(from: impl 'a + Fn(S) -> A, to: impl 'a + Fn(A) -> S) -> Self
Create a new monomorphic isomorphism from bidirectional conversion functions.
§Type Signature
forall PointerBrand S A. ToDynCloneFn PointerBrand => (S -> A, A -> S) -> IsoPrime PointerBrand S A
§Parameters
from: The forward conversion function.to: The backward conversion function.
§Returns
A new instance of the type.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::IsoPrime,
};
// Iso between a newtype and its inner value
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
assert_eq!(iso.from((10,)), 10);Sourcepub fn from(&self, s: S) -> A
pub fn from(&self, s: S) -> A
Apply the forward conversion.
§Type Signature
forall PointerBrand S A. ToDynCloneFn PointerBrand => (&IsoPrime PointerBrand S A, S) -> A
§Parameters
&self: The monomorphic iso instance.s: The structure to convert.
§Returns
The focus value.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::IsoPrime,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
assert_eq!(iso.from((42,)), 42);Sourcepub fn to(&self, a: A) -> S
pub fn to(&self, a: A) -> S
Apply the backward conversion.
§Type Signature
forall PointerBrand S A. ToDynCloneFn PointerBrand => (&IsoPrime PointerBrand S A, A) -> S
§Parameters
&self: The monomorphic iso instance.a: The focus value to convert.
§Returns
The structure value.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::IsoPrime,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
assert_eq!(iso.to(42), (42,));Sourcepub fn reversed(&self) -> IsoPrime<'a, PointerBrand, A, S>
pub fn reversed(&self) -> IsoPrime<'a, PointerBrand, A, S>
Reverse the isomorphism.
§Type Signature
forall PointerBrand S A. ToDynCloneFn PointerBrand => &IsoPrime PointerBrand S A -> IsoPrime PointerBrand A S
§Returns
A new IsoPrime instance with the forward and backward conversions swapped.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::IsoPrime,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let reversed = iso.reversed();
assert_eq!(reversed.from(42), (42,));
assert_eq!(reversed.to((42,)), 42);Trait Implementations§
Source§impl<'a, PointerBrand, S: 'a, A: 'a> AffineTraversalOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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: 'a, A: 'a> AffineTraversalOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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.
Source§fn evaluate<Q: Strong + Choice>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, A>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<Q: Strong + Choice>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, A>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall PointerBrand S A Q. (Strong Q, Choice Q, ToDynCloneFn PointerBrand) => (&IsoPrime PointerBrand S A, Q A A) -> Q S S
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The monomorphic iso instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let f = lift_fn_new::<RcFnBrand, _, _>(|x: i32| x + 1);
let modifier: std::rc::Rc<dyn Fn((i32,)) -> (i32,)> =
AffineTraversalOptic::evaluate::<RcFnBrand>(&iso, f);
assert_eq!(modifier((41,)), (42,));Source§impl<'a, PointerBrand, S, A> Clone for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a,
§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, A> Clone for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a,
§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.
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
§Type Signature
forall PointerBrand S A. ToDynCloneFn PointerBrand => &IsoPrime PointerBrand S A -> IsoPrime PointerBrand S A
§Returns
A new IsoPrime instance that is a copy of the original.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::IsoPrime,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let cloned = iso.clone();
assert_eq!(cloned.from((42,)), 42);1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a, PointerBrand, S: 'a, A: 'a> FoldOptic<'a, S, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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: 'a, A: 'a> FoldOptic<'a, S, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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.
Source§fn evaluate<R: 'a + Monoid + 'static, Q: ToDynCloneFn + 'static>(
&self,
pab: <ForgetBrand<Q, R> as Kind_266801a817966495>::Of<'a, A, A>,
) -> <ForgetBrand<Q, R> as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<R: 'a + Monoid + 'static, Q: ToDynCloneFn + 'static>( &self, pab: <ForgetBrand<Q, R> as Kind_266801a817966495>::Of<'a, A, A>, ) -> <ForgetBrand<Q, R> as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall PointerBrand S A R Q. (Monoid R, ToDynCloneFn Q, ToDynCloneFn PointerBrand) => (&IsoPrime PointerBrand S A, Forget Q R A A) -> Forget Q R S S
§Type Parameters
R: The monoid type.Q: The reference-counted pointer type.
§Parameters
&self: The monomorphic iso instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let f = Forget::<RcBrand, String, i32, i32>::new(|x| x.to_string());
let folded = FoldOptic::evaluate(&iso, f);
assert_eq!(folded.run((42,)), "42".to_string());Source§impl<'a, PointerBrand, S: 'a, A: 'a> GetterOptic<'a, S, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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: 'a, A: 'a> GetterOptic<'a, S, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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.
Source§fn evaluate<R: 'a + 'static, Q: ToDynCloneFn + 'static>(
&self,
pab: <ForgetBrand<Q, R> as Kind_266801a817966495>::Of<'a, A, A>,
) -> <ForgetBrand<Q, R> as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<R: 'a + 'static, Q: ToDynCloneFn + 'static>( &self, pab: <ForgetBrand<Q, R> as Kind_266801a817966495>::Of<'a, A, A>, ) -> <ForgetBrand<Q, R> as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall PointerBrand S A R Q. (ToDynCloneFn Q, ToDynCloneFn PointerBrand) => (&IsoPrime PointerBrand S A, Forget Q R A A) -> Forget Q R S S
§Type Parameters
R: The return type of the forget profunctor.Q: The reference-counted pointer type.
§Parameters
&self: The monomorphic iso instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let f = Forget::<RcBrand, i32, i32, i32>::new(|x| x);
let folded = GetterOptic::evaluate(&iso, f);
assert_eq!(folded.run((42,)), 42);Source§impl<'a, FunctionBrand: LiftFn, PointerBrand, S: 'a, A: 'a> GrateOptic<'a, FunctionBrand, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§Type Parameters
'a: The lifetime of the values.
FunctionBrand: The cloneable function brand used by the profunctor’s Closed instance.
PointerBrand: The reference-counted pointer type.
S: The type of the structure.
A: The type of the focus.
impl<'a, FunctionBrand: LiftFn, PointerBrand, S: 'a, A: 'a> GrateOptic<'a, FunctionBrand, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§Type Parameters
'a: The lifetime of the values.FunctionBrand: The cloneable function brand used by the profunctor’sClosedinstance.PointerBrand: The reference-counted pointer type.S: The type of the structure.A: The type of the focus.
Source§fn evaluate<Q: Closed<FunctionBrand>>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, A>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<Q: Closed<FunctionBrand>>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, A>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall FunctionBrand PointerBrand S A Q. (Closed Q, ToDynCloneFn PointerBrand) => (&IsoPrime FunctionBrand PointerBrand S A, Q A A) -> Q S S
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The monomorphic iso instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let f = lift_fn_new::<RcFnBrand, _, _>(|x: i32| x + 1);
let modifier: std::rc::Rc<dyn Fn((i32,)) -> (i32,)> =
GrateOptic::<RcFnBrand, _, _, _, _>::evaluate::<RcFnBrand>(&iso, f);
assert_eq!(modifier((41,)), (42,));Source§impl<'a, PointerBrand, S: 'a, A: 'a> IsoOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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: 'a, A: 'a> IsoOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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.
Source§fn evaluate<Q: Profunctor + 'static>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, A>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<Q: Profunctor + 'static>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, A>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall PointerBrand S A Q. (Profunctor Q, ToDynCloneFn PointerBrand) => (&IsoPrime PointerBrand S A, Q A A) -> Q S S
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The monomorphic iso instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let f = lift_fn_new::<RcFnBrand, _, _>(|x: i32| x + 1);
let modifier: std::rc::Rc<dyn Fn((i32,)) -> (i32,)> = IsoOptic::evaluate::<RcFnBrand>(&iso, f);
assert_eq!(modifier((41,)), (42,));Source§impl<'a, PointerBrand, S: 'a, A: 'a> LensOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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: 'a, A: 'a> LensOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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.
Source§fn evaluate<Q: Strong>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, A>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<Q: Strong>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, A>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall PointerBrand S A Q. (Strong Q, ToDynCloneFn PointerBrand) => (&IsoPrime PointerBrand S A, Q A A) -> Q S S
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The monomorphic iso instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let f = lift_fn_new::<RcFnBrand, _, _>(|x: i32| x + 1);
let modifier: std::rc::Rc<dyn Fn((i32,)) -> (i32,)> = LensOptic::evaluate::<RcFnBrand>(&iso, f);
assert_eq!(modifier((41,)), (42,));Source§impl<'a, Q, PointerBrand, S, A> Optic<'a, Q, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
Q: Profunctor,
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a,
§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> Optic<'a, Q, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
Q: Profunctor,
PointerBrand: ToDynCloneFn,
S: 'a,
A: 'a,
§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.
Source§fn evaluate(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, A>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, A>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall Q PointerBrand S A. (Profunctor Q, ToDynCloneFn PointerBrand) => (&IsoPrime Q PointerBrand S A, Q A A) -> Q S S
§Parameters
&self: The monomorphic iso instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let f = lift_fn_new::<RcFnBrand, _, _>(|x: i32| x + 1);
let modifier = Optic::<RcFnBrand, _, _, _, _>::evaluate(&iso, f);
assert_eq!(modifier((41,)), (42,));Source§impl<'a, PointerBrand, S: 'a, A: 'a> PrismOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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: 'a, A: 'a> PrismOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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.
Source§fn evaluate<Q: Choice>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, A>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<Q: Choice>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, A>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall PointerBrand S A Q. (Choice Q, ToDynCloneFn PointerBrand) => (&IsoPrime PointerBrand S A, Q A A) -> Q S S
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The monomorphic iso instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let f = lift_fn_new::<RcFnBrand, _, _>(|x: i32| x + 1);
let modifier: std::rc::Rc<dyn Fn((i32,)) -> (i32,)> =
PrismOptic::evaluate::<RcFnBrand>(&iso, f);
assert_eq!(modifier((41,)), (42,));Source§impl<'a, PointerBrand, S: 'a, A: 'a> ReviewOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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: 'a, A: 'a> ReviewOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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.
Source§fn evaluate(
&self,
pab: <TaggedBrand as Kind_266801a817966495>::Of<'a, A, A>,
) -> <TaggedBrand as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate( &self, pab: <TaggedBrand as Kind_266801a817966495>::Of<'a, A, A>, ) -> <TaggedBrand as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall PointerBrand S A. ToDynCloneFn PointerBrand => (&IsoPrime PointerBrand S A, Tagged A A) -> Tagged S S
§Parameters
&self: The monomorphic iso instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let f = Tagged::new(42);
let reviewed = ReviewOptic::evaluate(&iso, f);
assert_eq!(reviewed.0, (42,));Source§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 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.
Source§fn evaluate(
&self,
pab: <FnBrand<Q> as Kind_266801a817966495>::Of<'a, A, A>,
) -> <FnBrand<Q> as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate( &self, pab: <FnBrand<Q> as Kind_266801a817966495>::Of<'a, A, A>, ) -> <FnBrand<Q> as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall Q PointerBrand S A. (ToDynCloneFn PointerBrand, ToDynCloneFn Q) => (&IsoPrime Q PointerBrand S A, Fn Q A A) -> Fn Q S S
§Parameters
&self: The monomorphic iso instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let f = lift_fn_new::<RcFnBrand, _, _>(|x: i32| x + 1);
let modifier: std::rc::Rc<dyn Fn((i32,)) -> (i32,)> =
SetterOptic::<RcBrand, _, _, _, _>::evaluate(&iso, f);
assert_eq!(modifier((41,)), (42,));Source§impl<'a, PointerBrand, S: 'a, A: 'a> TraversalOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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: 'a, A: 'a> TraversalOptic<'a, S, S, A, A> for IsoPrime<'a, PointerBrand, S, A>where
PointerBrand: ToDynCloneFn,
§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.
Source§fn evaluate<Q: Wander>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, A>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
fn evaluate<Q: Wander>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, A>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, S>
§Type Signature
forall PointerBrand S A Q. (Wander Q, ToDynCloneFn PointerBrand) => (&IsoPrime PointerBrand S A, Q A A) -> Q S S
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The monomorphic iso instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let iso: IsoPrime<RcBrand, (i32,), i32> = IsoPrime::new(|(x,)| x, |x| (x,));
let f = lift_fn_new::<RcFnBrand, _, _>(|x: i32| x + 1);
let modifier: std::rc::Rc<dyn Fn((i32,)) -> (i32,)> =
TraversalOptic::evaluate::<RcFnBrand>(&iso, f);
assert_eq!(modifier((41,)), (42,));Auto Trait Implementations§
impl<'a, PointerBrand, S, A> Freeze for IsoPrime<'a, PointerBrand, S, A>where
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(S) -> A + 'a>: Freeze,
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(A) -> S + 'a>: Freeze,
impl<'a, PointerBrand, S, A> RefUnwindSafe for IsoPrime<'a, PointerBrand, S, A>where
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(S) -> A + 'a>: RefUnwindSafe,
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(A) -> S + 'a>: RefUnwindSafe,
impl<'a, PointerBrand, S, A> Send for IsoPrime<'a, PointerBrand, S, A>where
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(S) -> A + 'a>: Send,
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(A) -> S + 'a>: Send,
impl<'a, PointerBrand, S, A> Sync for IsoPrime<'a, PointerBrand, S, A>where
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(S) -> A + 'a>: Sync,
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(A) -> S + 'a>: Sync,
impl<'a, PointerBrand, S, A> Unpin for IsoPrime<'a, PointerBrand, S, A>where
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(S) -> A + 'a>: Unpin,
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(A) -> S + 'a>: Unpin,
impl<'a, PointerBrand, S, A> UnsafeUnpin for IsoPrime<'a, PointerBrand, S, A>where
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(S) -> A + 'a>: UnsafeUnpin,
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(A) -> S + 'a>: UnsafeUnpin,
impl<'a, PointerBrand, S, A> UnwindSafe for IsoPrime<'a, PointerBrand, S, A>where
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(S) -> A + 'a>: UnwindSafe,
<PointerBrand as RefCountedPointer>::Of<'a, dyn Fn(A) -> S + 'a>: UnwindSafe,
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