pub struct Review<'a, PointerBrand, S, T, A, B>where
PointerBrand: UnsizedCoercible,
S: 'a,
T: 'a,
A: 'a,
B: 'a,{
pub review_fn: <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, B, T>,
/* private fields */
}Expand description
A polymorphic review.
Matches PureScript’s Review s t a b.
§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.A: The source type of the focus.B: The target type of the focus.
Fields§
§review_fn: <FnBrand<PointerBrand> as Kind_266801a817966495>::Of<'a, B, T>Function to construct a structure from a focus value.
Implementations§
Source§impl<'a, PointerBrand, S, T, A, B> Review<'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.
A: The source type of the focus.
B: The target type of the focus.
impl<'a, PointerBrand, S, T, A, B> Review<'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.A: The source type of the focus.B: The target type of the focus.
Sourcepub fn new(review: impl 'a + Fn(B) -> T) -> Self
pub fn new(review: impl 'a + Fn(B) -> T) -> Self
Create a new polymorphic review from a review function.
§Type Signature
forall PointerBrand S T A B. UnsizedCoercible PointerBrand => (B -> T) -> Review PointerBrand S T A B
§Parameters
review: The review function.
§Returns
A new instance of the type.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::Review,
};
let r: Review<RcBrand, Option<i32>, Option<i32>, i32, i32> = Review::new(Some);
assert_eq!(r.review(42), Some(42));Sourcepub fn review(&self, b: B) -> T
pub fn review(&self, b: B) -> T
Review a focus value into a structure.
§Type Signature
forall PointerBrand S T A B. UnsizedCoercible PointerBrand => (&Review PointerBrand S T A B, B) -> T
§Parameters
&self: The review instance.b: The focus value to review.
§Returns
The structure containing the focus value.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::Review,
};
let r: Review<RcBrand, Option<i32>, Option<i32>, i32, i32> = Review::new(Some);
assert_eq!(r.review(42), Some(42));Trait Implementations§
Source§impl<'a, PointerBrand, S, T, A, B> Clone for Review<'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.
A: The source type of the focus.
B: The target type of the focus.
impl<'a, PointerBrand, S, T, A, B> Clone for Review<'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.A: The source type of the focus.B: The target type of the focus.
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
§Type Signature
forall PointerBrand S T A B. UnsizedCoercible PointerBrand => &Review PointerBrand S T A B -> Review PointerBrand S T A B
§Returns
A new Review instance that is a copy of the original.
§Examples
use fp_library::{
brands::RcBrand,
types::optics::Review,
};
let r: Review<RcBrand, Option<i32>, Option<i32>, i32, i32> = Review::new(Some);
let cloned = r.clone();
assert_eq!(cloned.review(42), Some(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, T, A, B> Optic<'a, TaggedBrand, S, T, A, B> for Review<'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.
A: The source type of the focus.
B: The target type of the focus.
impl<'a, PointerBrand, S, T, A, B> Optic<'a, TaggedBrand, S, T, A, B> for Review<'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.A: The source type of the focus.B: The target type of the focus.
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 => (&Review PointerBrand S T A B, Tagged A B) -> Tagged S T
§Parameters
&self: The review instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let r: Review<RcBrand, Option<i32>, Option<i32>, i32, i32> = Review::new(Some);
let f = Tagged::new(42);
let reviewed = Optic::<TaggedBrand, _, _, _, _>::evaluate(&r, f);
assert_eq!(reviewed.0, Some(42));Source§impl<'a, PointerBrand, S, T, A, B> ReviewOptic<'a, S, T, A, B> for Review<'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.
A: The source type of the focus.
B: The target type of the focus.
impl<'a, PointerBrand, S, T, A, B> ReviewOptic<'a, S, T, A, B> for Review<'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.A: The source type of the focus.B: The target type of the focus.
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 => (&Review PointerBrand S T A B, Tagged A B) -> Tagged S T
§Parameters
&self: The review instance.pab: The profunctor value to transform.
§Returns
The transformed profunctor value.
§Examples
use fp_library::{
brands::{
optics::*,
*,
},
classes::optics::*,
functions::*,
types::optics::*,
};
let r: Review<RcBrand, Option<i32>, Option<i32>, i32, i32> = Review::new(Some);
let f = Tagged::new(42);
let reviewed = ReviewOptic::evaluate(&r, f);
assert_eq!(reviewed.0, Some(42));Auto Trait Implementations§
impl<'a, PointerBrand, S, T, A, B> Freeze for Review<'a, PointerBrand, S, T, A, B>
impl<'a, PointerBrand, S, T, A, B> RefUnwindSafe for Review<'a, PointerBrand, S, T, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: RefUnwindSafe,
S: RefUnwindSafe,
A: RefUnwindSafe,
impl<'a, PointerBrand, S, T, A, B> Send for Review<'a, PointerBrand, S, T, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: Send,
S: Sync,
A: Sync,
impl<'a, PointerBrand, S, T, A, B> Sync for Review<'a, PointerBrand, S, T, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: Sync,
S: Sync,
A: Sync,
impl<'a, PointerBrand, S, T, A, B> Unpin for Review<'a, PointerBrand, S, T, A, B>
impl<'a, PointerBrand, S, T, A, B> UnsafeUnpin for Review<'a, PointerBrand, S, T, A, B>
impl<'a, PointerBrand, S, T, A, B> UnwindSafe for Review<'a, PointerBrand, S, T, A, B>where
<PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: UnwindSafe,
S: RefUnwindSafe,
A: 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