Skip to main content

Review

Struct Review 

Source
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.
Source

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));
Source

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.
Source§

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)

Performs copy-assignment from source. Read more
Source§

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>

§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.
Source§

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>
where <PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: Freeze,

§

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>
where <PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: Unpin,

§

impl<'a, PointerBrand, S, T, A, B> UnsafeUnpin for Review<'a, PointerBrand, S, T, A, B>
where <PointerBrand as RefCountedPointer>::CloneableOf<'a, dyn Fn(B) -> T + 'a>: UnsafeUnpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.