pub struct Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
S: 'a,
T: 'a,
A: 'a,
B: 'a,{
pub from: <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, S, A>,
pub to: <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, B, T>,
}Expand description
A polymorphic isomorphism where types can change.
This matches PureScript’s Iso s t a b.
An isomorphism represents a lossless bidirectional conversion between types.
Uses FnBrand to support capturing closures.
§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.
Fields§
§from: <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, S, A>Forward conversion: from structure to focus.
to: <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, B, T>Backward conversion: from focus to structure.
Implementations§
Source§impl<'a, PointerBrand, S: 'a, T: 'a, A: 'a, B: 'a> Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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: 'a, T: 'a, A: 'a, B: 'a> Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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.
Sourcepub fn new(from: impl 'a + Fn(S) -> A, to: impl 'a + Fn(B) -> T) -> Self
pub fn new(from: impl 'a + Fn(S) -> A, to: impl 'a + Fn(B) -> T) -> Self
Create a new polymorphic isomorphism.
§Type Signature
forall PointerBrand S T A B. UnsizedCoercible PointerBrand => (S -> A, B -> T) -> Iso PointerBrand S T A B
§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::Iso,
};
// Iso between String and Vec<char>
let string_chars: Iso<RcBrand, String, String, Vec<char>, Vec<char>> =
Iso::new(|s: String| s.chars().collect(), |v: Vec<char>| v.into_iter().collect());
assert_eq!(string_chars.from("hi".to_string()), vec!['h', 'i']);Sourcepub fn from(&self, s: S) -> A
pub fn from(&self, s: S) -> A
Apply the forward conversion.
§Type Signature
forall PointerBrand S T A B. UnsizedCoercible PointerBrand => (&Iso PointerBrand S T A B, S) -> A
§Parameters
&self: The iso instance.s: The structure to convert.
§Returns
The focus value.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::Iso,
};
let string_chars: Iso<RcBrand, String, String, Vec<char>, Vec<char>> =
Iso::new(|s: String| s.chars().collect(), |v: Vec<char>| v.into_iter().collect());
let chars = string_chars.from("hello".to_string());
assert_eq!(chars, vec!['h', 'e', 'l', 'l', 'o']);Sourcepub fn to(&self, b: B) -> T
pub fn to(&self, b: B) -> T
Apply the backward conversion.
§Type Signature
forall PointerBrand S T A B. UnsizedCoercible PointerBrand => (&Iso PointerBrand S T A B, B) -> T
§Parameters
&self: The iso instance.b: The focus value to convert.
§Returns
The structure value.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::Iso,
};
let string_chars: Iso<RcBrand, String, String, Vec<char>, Vec<char>> =
Iso::new(|s: String| s.chars().collect(), |v: Vec<char>| v.into_iter().collect());
let s = string_chars.to(vec!['h', 'i']);
assert_eq!(s, "hi");Trait Implementations§
Source§impl<'a, PointerBrand, S: 'a, T: 'a, A: 'a, B: 'a> AffineTraversalOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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: 'a, T: 'a, A: 'a, B: 'a> AffineTraversalOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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.
Source§fn evaluate<Q: Strong + Choice>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, B>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<Q: Strong + Choice>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall PointerBrand S T A B Q. (Strong Q, Choice Q, UnsizedCoercible PointerBrand) => (&Iso PointerBrand S T A B, Q A B) -> Q S T
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The 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: Iso<RcBrand, (i32,), (i32,), i32, i32> = Iso::new(|(x,)| x, |x| (x,));
let f = cloneable_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, T, A, B> Clone for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
S: 'a,
T: 'a,
A: 'a,
B: 'a,
§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, A, B> Clone for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
S: 'a,
T: 'a,
A: 'a,
B: 'a,
§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.
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
§Type Signature
forall PointerBrand S T A B. UnsizedCoercible PointerBrand => &Iso PointerBrand S T A B -> Iso PointerBrand S T A B
§Returns
A new Iso instance that is a copy of the original.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::Iso,
};
let string_chars: Iso<RcBrand, String, String, Vec<char>, Vec<char>> =
Iso::new(|s: String| s.chars().collect(), |v: Vec<char>| v.into_iter().collect());
let cloned = string_chars.clone();
assert_eq!(cloned.from("hi".to_string()), vec!['h', 'i']);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 Iso<'a, PointerBrand, S, S, A, A>where
PointerBrand: UnsizedCoercible,
§Type Parameters
'a: The lifetime of the values.
PointerBrand: The reference-counted pointer type.
S: The source type of the structure.
A: The focus type.
impl<'a, PointerBrand, S: 'a, A: 'a> FoldOptic<'a, S, A> for Iso<'a, PointerBrand, S, S, A, A>where
PointerBrand: UnsizedCoercible,
§Type Parameters
'a: The lifetime of the values.PointerBrand: The reference-counted pointer type.S: The source type of the structure.A: The focus type.
Source§fn evaluate<R: 'a + Monoid + 'static, Q: UnsizedCoercible + '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: UnsizedCoercible + '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, UnsizedCoercible Q, UnsizedCoercible PointerBrand) => (&Iso 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 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: Iso<RcBrand, (i32,), (i32,), i32, i32> = Iso::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 Iso<'a, PointerBrand, S, S, A, A>where
PointerBrand: UnsizedCoercible,
§Type Parameters
'a: The lifetime of the values.
PointerBrand: The reference-counted pointer type.
S: The source type of the structure.
A: The focus type.
impl<'a, PointerBrand, S: 'a, A: 'a> GetterOptic<'a, S, A> for Iso<'a, PointerBrand, S, S, A, A>where
PointerBrand: UnsizedCoercible,
§Type Parameters
'a: The lifetime of the values.PointerBrand: The reference-counted pointer type.S: The source type of the structure.A: The focus type.
Source§fn evaluate<R: 'a + 'static, Q: UnsizedCoercible + '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: UnsizedCoercible + '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. (UnsizedCoercible Q, UnsizedCoercible PointerBrand) => (&Iso 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 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: Iso<RcBrand, (i32,), (i32,), i32, i32> = Iso::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: CloneableFn, PointerBrand, S: 'a, T: 'a, A: 'a, B: 'a> GrateOptic<'a, FunctionBrand, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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 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, FunctionBrand: CloneableFn, PointerBrand, S: 'a, T: 'a, A: 'a, B: 'a> GrateOptic<'a, FunctionBrand, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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 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.
Source§fn evaluate<Q: Closed<FunctionBrand>>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, B>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<Q: Closed<FunctionBrand>>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall PointerBrand S T A B Q. (Closed Q, UnsizedCoercible PointerBrand) => (&Iso FunctionBrand PointerBrand S T A B, Q A B) -> Q S T
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The 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: Iso<RcBrand, (i32,), (i32,), i32, i32> = Iso::new(|(x,)| x, |x| (x,));
let f = cloneable_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, T: 'a, A: 'a, B: 'a> IsoOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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: 'a, T: 'a, A: 'a, B: 'a> IsoOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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.
Source§fn evaluate<Q: Profunctor + 'static>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, B>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<Q: Profunctor + 'static>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall PointerBrand S T A B Q. (Profunctor Q, UnsizedCoercible PointerBrand) => (&Iso PointerBrand S T A B, Q A B) -> Q S T
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The 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: Iso<RcBrand, (i32,), (i32,), i32, i32> = Iso::new(|(x,)| x, |x| (x,));
let f = cloneable_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, T: 'a, A: 'a, B: 'a> LensOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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: 'a, T: 'a, A: 'a, B: 'a> LensOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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.
Source§fn evaluate<Q: Strong>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, B>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<Q: Strong>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall PointerBrand S T A B Q. (Strong Q, UnsizedCoercible PointerBrand) => (&Iso PointerBrand S T A B, Q A B) -> Q S T
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The 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: Iso<RcBrand, (i32,), (i32,), i32, i32> = Iso::new(|(x,)| x, |x| (x,));
let f = cloneable_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, T, A, B> Optic<'a, Q, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
Q: Profunctor,
PointerBrand: UnsizedCoercible,
S: 'a,
T: 'a,
A: 'a,
B: 'a,
§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, T, A, B> Optic<'a, Q, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
Q: Profunctor,
PointerBrand: UnsizedCoercible,
S: 'a,
T: 'a,
A: 'a,
B: 'a,
§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.
Source§fn evaluate(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, B>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall Q PointerBrand S T A B. (Profunctor Q, UnsizedCoercible PointerBrand) => (&Iso Q PointerBrand S T A B, Q A B) -> Q S T
§Parameters
&self: The 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: Iso<RcBrand, (i32,), (i32,), i32, i32> = Iso::new(|(x,)| x, |x| (x,));
let f = cloneable_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, T: 'a, A: 'a, B: 'a> PrismOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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: 'a, T: 'a, A: 'a, B: 'a> PrismOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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.
Source§fn evaluate<Q: Choice>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, B>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<Q: Choice>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall PointerBrand S T A B Q. (Choice Q, UnsizedCoercible PointerBrand) => (&Iso PointerBrand S T A B, Q A B) -> Q S T
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The 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: Iso<RcBrand, (i32,), (i32,), i32, i32> = Iso::new(|(x,)| x, |x| (x,));
let f = cloneable_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, T: 'a, A: 'a, B: 'a> ReviewOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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: 'a, T: 'a, A: 'a, B: 'a> ReviewOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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.
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 PointerBrand S T A B. UnsizedCoercible PointerBrand => (&Iso PointerBrand S T A B, Tagged A B) -> Tagged S T
§Parameters
&self: The 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: Iso<RcBrand, (i32,), (i32,), i32, i32> = Iso::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, T: 'a, A: 'a, B: 'a> SetterOptic<'a, Q, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
Q: UnsizedCoercible,
§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 Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
Q: UnsizedCoercible,
§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.
Source§fn evaluate(
&self,
pab: <FnBrand<Q> as Kind_266801a817966495>::Of<'a, A, B>,
) -> <FnBrand<Q> as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate( &self, pab: <FnBrand<Q> as Kind_266801a817966495>::Of<'a, A, B>, ) -> <FnBrand<Q> as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall Q PointerBrand S T A B. (UnsizedCoercible PointerBrand, UnsizedCoercible Q) => (&Iso Q PointerBrand S T A B, Fn Q A B) -> Fn Q S T
§Parameters
&self: The 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: Iso<RcBrand, (i32,), (i32,), i32, i32> = Iso::new(|(x,)| x, |x| (x,));
let f = cloneable_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, T: 'a, A: 'a, B: 'a> TraversalOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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: 'a, T: 'a, A: 'a, B: 'a> TraversalOptic<'a, S, T, A, B> for Iso<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
§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.
Source§fn evaluate<Q: Wander>(
&self,
pab: <Q as Kind_266801a817966495>::Of<'a, A, B>,
) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
fn evaluate<Q: Wander>( &self, pab: <Q as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Q as Kind_266801a817966495>::Of<'a, S, T>
§Type Signature
forall PointerBrand S T A B Q. (Wander Q, UnsizedCoercible PointerBrand) => (&Iso PointerBrand S T A B, Q A B) -> Q S T
§Type Parameters
Q: The profunctor type.
§Parameters
&self: The 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: Iso<RcBrand, (i32,), (i32,), i32, i32> = Iso::new(|(x,)| x, |x| (x,));
let f = cloneable_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, T, A, B> Freeze for Iso<'a, PointerBrand, S, T, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(S) -> A + 'a>: Freeze,
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: Freeze,
impl<'a, PointerBrand, S, T, A, B> RefUnwindSafe for Iso<'a, PointerBrand, S, T, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(S) -> A + 'a>: RefUnwindSafe,
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: RefUnwindSafe,
impl<'a, PointerBrand, S, T, A, B> Send for Iso<'a, PointerBrand, S, T, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(S) -> A + 'a>: Send,
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: Send,
impl<'a, PointerBrand, S, T, A, B> Sync for Iso<'a, PointerBrand, S, T, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(S) -> A + 'a>: Sync,
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: Sync,
impl<'a, PointerBrand, S, T, A, B> Unpin for Iso<'a, PointerBrand, S, T, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(S) -> A + 'a>: Unpin,
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: Unpin,
impl<'a, PointerBrand, S, T, A, B> UnsafeUnpin for Iso<'a, PointerBrand, S, T, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(S) -> A + 'a>: UnsafeUnpin,
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: UnsafeUnpin,
impl<'a, PointerBrand, S, T, A, B> UnwindSafe for Iso<'a, PointerBrand, S, T, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(S) -> A + 'a>: UnwindSafe,
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + '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