Skip to main content

ForgetBrand

Struct ForgetBrand 

Source
pub struct ForgetBrand<PointerBrand, R>(/* private fields */);
Expand description

Brand for the Forget profunctor.

§Type Parameters

  • PointerBrand: The pointer brand.
  • R: The return type of the function.

Trait Implementations§

Source§

impl<PointerBrand: ToDynCloneFn + 'static, R: 'static + Monoid> Choice for ForgetBrand<PointerBrand, R>

§Type Parameters
  • PointerBrand: The pointer brand.
  • R: The return type of the function.
Source§

fn left<'a, A: 'a, B: 'a, C: 'a>( pab: <Self as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Self as Kind_266801a817966495>::Of<'a, Result<C, A>, Result<C, B>>

Lifts the Forget profunctor to operate on the left component of a Result.

§Type Signature

forall PointerBrand R A B C. (ToDynCloneFn PointerBrand, Monoid R) => Forget PointerBrand R A B A B -> Forget PointerBrand R A B (Result C A) (Result C B)

§Type Parameters
  • 'a: The lifetime of the functions.
  • A: The type of the left component.
  • B: The type of the target left component.
  • C: The type of the right component.
§Parameters
  • pab: The forget instance to transform.
§Returns

A transformed Forget instance that operates on Result types.

§Examples
use fp_library::{
	brands::{
		optics::*,
		*,
	},
	classes::{
		optics::*,
		profunctor::*,
		*,
	},
	types::optics::*,
};

let forget: Forget<RcBrand, String, String, String> = Forget::new(|x: String| x);

let transformed =
	<ForgetBrand<RcBrand, String> as Choice>::left::<String, String, String>(forget);
assert_eq!(transformed.run(Err("hello".to_string())), "hello".to_string());
assert_eq!(transformed.run(Ok("world".to_string())), "".to_string());
Source§

fn right<'a, A: 'a, B: 'a, C: 'a>( pab: <Self as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Self as Kind_266801a817966495>::Of<'a, Result<A, C>, Result<B, C>>

Lifts the Forget profunctor to operate on the right component of a Result.

§Type Signature

forall PointerBrand R A B C. (ToDynCloneFn PointerBrand, Monoid R) => Forget PointerBrand R A B A B -> Forget PointerBrand R A B (Result A C) (Result B C)

§Type Parameters
  • 'a: The lifetime of the functions.
  • A: The type of the left component.
  • B: The type of the right component.
  • C: The target type of the right component.
§Parameters
  • pab: The forget instance to transform.
§Returns

A transformed Forget instance that operates on Result types.

§Examples
use fp_library::{
	brands::{
		optics::*,
		*,
	},
	classes::{
		optics::*,
		profunctor::*,
		*,
	},
	types::optics::*,
};

let forget: Forget<RcBrand, String, String, String> = Forget::new(|x: String| x);

let transformed =
	<ForgetBrand<RcBrand, String> as Choice>::right::<String, String, String>(forget);
assert_eq!(transformed.run(Ok("hello".to_string())), "hello".to_string());
assert_eq!(transformed.run(Err("world".to_string())), "".to_string());
Source§

impl<PointerBrand: Clone, R: Clone> Clone for ForgetBrand<PointerBrand, R>

Source§

fn clone(&self) -> ForgetBrand<PointerBrand, R>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<PointerBrand: ToDynCloneFn + 'static, R: 'static> Cochoice for ForgetBrand<PointerBrand, R>

§Type Parameters
  • PointerBrand: The pointer brand.
  • R: The return type of the function.
Source§

fn unleft<'a, A: 'a, B: 'a, C: 'a>( pab: <Self as Kind_266801a817966495>::Of<'a, Result<C, A>, Result<C, B>>, ) -> <Self as Kind_266801a817966495>::Of<'a, A, B>

Extracts a Forget profunctor from one operating on the left (Err) variant of a Result.

Given a Forget that operates on Result<C, A>, produces a Forget that operates on A by wrapping the input in Err before applying the original function.

§Type Signature

forall PointerBrand R A B C. ToDynCloneFn PointerBrand => Forget PointerBrand R A B (Result C A) (Result C B) -> Forget PointerBrand R A B A B

§Type Parameters
  • 'a: The lifetime of the functions.
  • A: The input type of the resulting profunctor.
  • B: The output type of the resulting profunctor.
  • C: The type of the alternative (Ok) variant.
§Parameters
  • pab: The forget instance to extract from.
§Returns

A Forget profunctor operating on the unwrapped types.

§Examples
use fp_library::{
	brands::{
		optics::*,
		*,
	},
	classes::{
		optics::*,
		profunctor::*,
		*,
	},
	types::optics::*,
};

let forget: Forget<RcBrand, String, Result<i32, String>, Result<i32, String>> =
	Forget::new(|r: Result<i32, String>| match r {
		Err(s) => s,
		Ok(n) => n.to_string(),
	});

let extracted =
	<ForgetBrand<RcBrand, String> as Cochoice>::unleft::<String, String, i32>(forget);
assert_eq!(extracted.run("hello".to_string()), "hello".to_string());
Source§

fn unright<'a, A: 'a, B: 'a, C: 'a>( pab: <Self as Kind_266801a817966495>::Of<'a, Result<A, C>, Result<B, C>>, ) -> <Self as Kind_266801a817966495>::Of<'a, A, B>

Extracts a Forget profunctor from one operating on the right (Ok) variant of a Result.

Given a Forget that operates on Result<A, C>, produces a Forget that operates on A by wrapping the input in Ok before applying the original function.

§Type Signature

forall PointerBrand R A B C. ToDynCloneFn PointerBrand => Forget PointerBrand R A B (Result A C) (Result B C) -> Forget PointerBrand R A B A B

§Type Parameters
  • 'a: The lifetime of the functions.
  • A: The input type of the resulting profunctor.
  • B: The output type of the resulting profunctor.
  • C: The type of the alternative (Err) variant.
§Parameters
  • pab: The forget instance to extract from.
§Returns

A Forget profunctor operating on the unwrapped types.

§Examples
use fp_library::{
	brands::{
		optics::*,
		*,
	},
	classes::{
		optics::*,
		profunctor::*,
		*,
	},
	types::optics::*,
};

let forget: Forget<RcBrand, String, Result<String, i32>, Result<String, i32>> =
	Forget::new(|r: Result<String, i32>| match r {
		Ok(s) => s,
		Err(n) => n.to_string(),
	});

let extracted =
	<ForgetBrand<RcBrand, String> as Cochoice>::unright::<String, String, i32>(forget);
assert_eq!(extracted.run("hello".to_string()), "hello".to_string());
Source§

impl<PointerBrand: Debug, R: Debug> Debug for ForgetBrand<PointerBrand, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<PointerBrand: Default, R: Default> Default for ForgetBrand<PointerBrand, R>

Source§

fn default() -> ForgetBrand<PointerBrand, R>

Returns the “default value” for a type. Read more
Source§

impl<PointerBrand: Hash, R: Hash> Hash for ForgetBrand<PointerBrand, R>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a, Q2: ToDynCloneFn + 'static, R: 'a + Monoid + Clone + 'static, PointerBrand: ToDynCloneFn, I: 'a, S: 'a, T: 'a, A: 'a, B: 'a, F> IndexedOpticAdapter<'a, ForgetBrand<Q2, R>, I, S, S, A, A> for IndexedFold<'a, PointerBrand, I, S, T, A, B, F>
where F: IndexedFoldFunc<'a, I, S, A> + Clone + 'a,

§Type Parameters
  • 'a: The lifetime of the values.
  • Q2: The result type brand.
  • R: The monoid type.
  • PointerBrand: The original profunctor type.
  • I: The index type.
  • S: The source type.
  • T: The target type.
  • A: The source focus type.
  • B: The target focus type.
  • F: The fold function type.
Source§

fn evaluate_indexed( &self, pab: Indexed<'a, ForgetBrand<Q2, R>, I, A, A>, ) -> Forget<'a, Q2, R, S, S>

§Type Signature

forall Q2 R PointerBrand I S T A B F. (ToDynCloneFn Q2, Monoid R, ToDynCloneFn PointerBrand, IndexedFoldFunc F) => (&IndexedFold Q2 R PointerBrand I S T A B F, Indexed (Forget Q2 R) I A A) -> Forget Q2 R S S

§Parameters
  • &self: The indexed fold instance.
  • pab: The indexed profunctor value.
§Returns

The transformed profunctor value.

§Examples
use fp_library::{
	brands::{
		RcBrand,
		VecBrand,
		optics::*,
	},
	functions::*,
	types::optics::{
		Folded,
		*,
	},
};
let l = IndexedFold::<RcBrand, usize, Vec<i32>, Vec<i32>, i32, i32, Folded<VecBrand>>::folded();
let _unindexed = optics_un_index::<ForgetBrand<RcBrand, String>, _, _, _, _, _>(&l);
assert_eq!(
	optics_indexed_fold_map::<RcBrand, _, _, _, String>(&l, |_, x| x.to_string(), vec![1, 2]),
	"12"
);
Source§

impl<'a, Q2: ToDynCloneFn + 'static, R: 'a + Monoid + Clone + 'static, PointerBrand: ToDynCloneFn, I: 'a, S: 'a, A: 'a, F> IndexedOpticAdapter<'a, ForgetBrand<Q2, R>, I, S, S, A, A> for IndexedFoldPrime<'a, PointerBrand, I, S, A, F>
where F: IndexedFoldFunc<'a, I, S, A> + Clone + 'a,

§Type Parameters
  • 'a: The lifetime of the values.
  • Q2: The result type brand.
  • R: The monoid type.
  • PointerBrand: The original profunctor type.
  • I: The index type.
  • S: The structure type.
  • A: The focus type.
  • F: The fold function type.
Source§

fn evaluate_indexed( &self, pab: Indexed<'a, ForgetBrand<Q2, R>, I, A, A>, ) -> Forget<'a, Q2, R, S, S>

§Type Signature

forall Q2 R PointerBrand I S A F. (ToDynCloneFn Q2, Monoid R, ToDynCloneFn PointerBrand, IndexedFoldFunc F) => (&IndexedFoldPrime Q2 R PointerBrand I S A F, Indexed (Forget Q2 R) I A A) -> Forget Q2 R S S

§Parameters
  • &self: The indexed fold instance.
  • pab: The indexed profunctor value.
§Returns

The transformed profunctor value.

§Examples
use fp_library::{
	brands::{
		RcBrand,
		VecBrand,
		optics::*,
	},
	functions::*,
	types::optics::{
		Folded,
		*,
	},
};
let l = IndexedFoldPrime::<RcBrand, usize, Vec<i32>, i32, Folded<VecBrand>>::folded();
let _unindexed = optics_un_index::<ForgetBrand<RcBrand, String>, _, _, _, _, _>(&l);
assert_eq!(
	optics_indexed_fold_map::<RcBrand, _, _, _, String>(&l, |_, x| x.to_string(), vec![1, 2]),
	"12"
);
Source§

impl<'a, Q2: ToDynCloneFn + 'static, R: 'a + 'static, PointerBrand: ToDynCloneFn, I: 'a, S: 'a, A: 'a> IndexedOpticAdapter<'a, ForgetBrand<Q2, R>, I, S, S, A, A> for IndexedGetter<'a, PointerBrand, I, S, A>

§Type Parameters
  • 'a: The lifetime of the values.
  • Q2: The result type brand.
  • R: The result type.
  • PointerBrand: The original pointer type.
  • I: The index type.
  • S: The structure type.
  • A: The focus type.
Source§

fn evaluate_indexed( &self, pab: Indexed<'a, ForgetBrand<Q2, R>, I, A, A>, ) -> Forget<'a, Q2, R, S, S>

§Type Signature

forall Q2 R PointerBrand I S A. (ToDynCloneFn Q2, ToDynCloneFn PointerBrand) => (&IndexedGetter Q2 R PointerBrand I S A, Indexed (Forget Q2 R) I A A) -> Forget Q2 R S S

§Parameters
  • &self: The indexed getter instance.
  • pab: The indexed profunctor value.
§Returns

The transformed profunctor value.

§Examples
use fp_library::{
	brands::{
		RcBrand,
		optics::*,
	},
	functions::*,
	types::optics::*,
};
let g: IndexedGetter<RcBrand, usize, (i32, String), i32> = IndexedGetter::new(|(x, _)| (0, x));
let result = optics_indexed_view::<RcBrand, _, _, _>(&g, (42, "hi".to_string()));
assert_eq!(result, (0, 42));
Source§

impl<'a, Q2: ToDynCloneFn + 'static, R: 'a + Monoid + Clone + 'static, PointerBrand: ToDynCloneFn, I: 'a, S: 'a, T: 'a, A: 'a, B: 'a, F> IndexedOpticAdapterDiscardsFocus<'a, ForgetBrand<Q2, R>, I, S, S, A, A> for IndexedFold<'a, PointerBrand, I, S, T, A, B, F>
where F: IndexedFoldFunc<'a, I, S, A> + Clone + 'a,

§Type Parameters
  • 'a: The lifetime of the values.
  • Q2: The result type brand.
  • R: The monoid type.
  • PointerBrand: The original profunctor type.
  • I: The index type.
  • S: The source type.
  • T: The target type.
  • A: The source focus type.
  • B: The target focus type.
  • F: The fold function type.
Source§

fn evaluate_indexed_discards_focus( &self, pab: Indexed<'a, ForgetBrand<Q2, R>, I, A, A>, ) -> Forget<'a, Q2, R, S, S>

§Type Signature

forall Q2 R PointerBrand I S T A B F. (ToDynCloneFn Q2, Monoid R, ToDynCloneFn PointerBrand, IndexedFoldFunc F) => (&IndexedFold Q2 R PointerBrand I S T A B F, Indexed (Forget Q2 R) I A A) -> Forget Q2 R S S

§Parameters
  • &self: The indexed fold instance.
  • pab: The indexed profunctor value.
§Returns

The transformed profunctor value.

§Examples
use fp_library::{
	brands::{
		RcBrand,
		VecBrand,
		optics::*,
	},
	functions::*,
	types::optics::{
		Folded,
		*,
	},
};
let l = IndexedFold::<RcBrand, usize, Vec<i32>, Vec<i32>, i32, i32, Folded<VecBrand>>::folded();
let _unindexed = optics_as_index::<ForgetBrand<RcBrand, String>, _, _, _, _, _>(&l);
assert_eq!(
	optics_indexed_fold_map::<RcBrand, _, _, _, String>(&l, |i, _| i.to_string(), vec![1, 2]),
	"01"
);
Source§

impl<'a, Q2: ToDynCloneFn + 'static, R: 'a + Monoid + Clone + 'static, PointerBrand: ToDynCloneFn, I: 'a, S: 'a, A: 'a, F> IndexedOpticAdapterDiscardsFocus<'a, ForgetBrand<Q2, R>, I, S, S, A, A> for IndexedFoldPrime<'a, PointerBrand, I, S, A, F>
where F: IndexedFoldFunc<'a, I, S, A> + Clone + 'a,

§Type Parameters
  • 'a: The lifetime of the values.
  • Q2: The result type brand.
  • R: The monoid type.
  • PointerBrand: The original profunctor type.
  • I: The index type.
  • S: The structure type.
  • A: The focus type.
  • F: The fold function type.
Source§

fn evaluate_indexed_discards_focus( &self, pab: Indexed<'a, ForgetBrand<Q2, R>, I, A, A>, ) -> Forget<'a, Q2, R, S, S>

§Type Signature

forall Q2 R PointerBrand I S A F. (ToDynCloneFn Q2, Monoid R, ToDynCloneFn PointerBrand, IndexedFoldFunc F) => (&IndexedFoldPrime Q2 R PointerBrand I S A F, Indexed (Forget Q2 R) I A A) -> Forget Q2 R S S

§Parameters
  • &self: The indexed fold instance.
  • pab: The indexed profunctor value.
§Returns

The transformed profunctor value.

§Examples
use fp_library::{
	brands::{
		RcBrand,
		VecBrand,
		optics::*,
	},
	functions::*,
	types::optics::{
		Folded,
		*,
	},
};
let l = IndexedFoldPrime::<RcBrand, usize, Vec<i32>, i32, Folded<VecBrand>>::folded();
let _unindexed = optics_as_index::<ForgetBrand<RcBrand, String>, _, _, _, _, _>(&l);
assert_eq!(
	optics_indexed_fold_map::<RcBrand, _, _, _, String>(&l, |i, _| i.to_string(), vec![1, 2]),
	"01"
);
Source§

impl<'a, Q2: ToDynCloneFn + 'static, R: 'a + 'static, PointerBrand: ToDynCloneFn, I: 'a, S: 'a, A: 'a> IndexedOpticAdapterDiscardsFocus<'a, ForgetBrand<Q2, R>, I, S, S, A, A> for IndexedGetter<'a, PointerBrand, I, S, A>

§Type Parameters
  • 'a: The lifetime of the values.
  • Q2: The result type brand.
  • R: The result type.
  • PointerBrand: The original pointer type.
  • I: The index type.
  • S: The structure type.
  • A: The focus type.
Source§

fn evaluate_indexed_discards_focus( &self, pab: Indexed<'a, ForgetBrand<Q2, R>, I, A, A>, ) -> Forget<'a, Q2, R, S, S>

§Type Signature

forall Q2 R PointerBrand I S A. (ToDynCloneFn Q2, ToDynCloneFn PointerBrand) => (&IndexedGetter Q2 R PointerBrand I S A, Indexed (Forget Q2 R) I A A) -> Forget Q2 R S S

§Parameters
  • &self: The indexed getter instance.
  • pab: The indexed profunctor value.
§Returns

The transformed profunctor value.

§Examples
use fp_library::{
	brands::{
		RcBrand,
		optics::*,
	},
	functions::*,
	types::optics::*,
};
let g: IndexedGetter<RcBrand, usize, (i32, String), i32> = IndexedGetter::new(|(x, _)| (10, x));
let result = optics_indexed_fold_map::<RcBrand, _, _, _, String>(
	&g,
	|i, _| format!("{}", i),
	(42, "hi".to_string()),
);
assert_eq!(result, "10");
Source§

impl<'a, A: 'a, B: 'a, PointerBrand: ToDynCloneFn + 'static, R: 'static> InferableBrand_266801a817966495<'a, ForgetBrand<PointerBrand, R>, A, B> for Forget<'a, PointerBrand, R, A, B>

Generated InferableBrand_266801a817966495 implementation for Forget < 'a, PointerBrand, R, A, B > with brand ForgetBrand < PointerBrand, R >.

Source§

type Marker = Val

Dispatch marker: Val for owned types, Ref for references.
Source§

impl<PointerBrand: ToDynCloneFn + 'static, R: 'static> Kind_266801a817966495 for ForgetBrand<PointerBrand, R>

Generated implementation of Kind_266801a817966495 for ForgetBrand < PointerBrand, R >.

Source§

type Of<'a, A: 'a, B: 'a> = Forget<'a, PointerBrand, R, A, B>

The applied type.
Source§

impl<'a, PointerBrand, S, A, R, Q> Optic<'a, ForgetBrand<Q, R>, S, S, A, A> for GetterPrime<'a, PointerBrand, S, A>
where PointerBrand: ToDynCloneFn, Q: ToDynCloneFn + 'static, S: 'a, A: 'a, R: 'a + 'static,

§Type Parameters
  • 'a: The lifetime of the values.
  • PointerBrand: The reference-counted pointer type for the getter.
  • S: The type of the structure.
  • A: The type of the focus.
  • R: The return type of the forget profunctor.
  • Q: The reference-counted pointer type for the forget brand.
Source§

fn evaluate( &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 PointerBrand, ToDynCloneFn Q) => (&GetterPrime PointerBrand S A R Q, Forget Q R A A) -> Forget Q R S S

§Parameters
  • &self: The getter instance.
  • pab: The profunctor value to transform.
§Returns

The transformed profunctor value.

§Examples
use fp_library::{
	brands::{
		optics::*,
		*,
	},
	classes::optics::*,
	functions::*,
	types::optics::*,
};

let g: GetterPrime<RcBrand, (i32, String), i32> = GetterPrime::new(|(x, _)| x);
let f = Forget::<RcBrand, i32, i32, i32>::new(|x| x);
let folded = Optic::<ForgetBrand<RcBrand, i32>, _, _, _, _>::evaluate(&g, f);
assert_eq!(folded.run((42, "hi".to_string())), 42);
Source§

impl<'a, PointerBrand, S, T, A, B, R, Q> Optic<'a, ForgetBrand<Q, R>, S, T, A, B> for Getter<'a, PointerBrand, S, T, A, B>
where PointerBrand: ToDynCloneFn, Q: ToDynCloneFn + 'static, S: 'a, T: 'a, A: 'a, B: 'a, R: 'a + 'static,

§Type Parameters
  • 'a: The lifetime of the values.
  • PointerBrand: The reference-counted pointer type for the getter.
  • 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.
  • R: The return type of the forget profunctor.
  • Q: The reference-counted pointer type for the forget brand.
Source§

fn evaluate( &self, pab: <ForgetBrand<Q, R> as Kind_266801a817966495>::Of<'a, A, B>, ) -> <ForgetBrand<Q, R> as Kind_266801a817966495>::Of<'a, S, T>

§Type Signature

forall PointerBrand S T A B R Q. (ToDynCloneFn PointerBrand, ToDynCloneFn Q) => (&Getter PointerBrand S T A B R Q, Forget Q R A B) -> Forget Q R S T

§Parameters
  • &self: The getter instance.
  • pab: The profunctor value to transform.
§Returns

The transformed profunctor value.

§Examples
use fp_library::{
	brands::{
		optics::*,
		*,
	},
	classes::optics::*,
	functions::*,
	types::optics::*,
};

let g: Getter<RcBrand, (i32, String), (i32, String), i32, i32> = Getter::new(|(x, _)| x);
let f = Forget::<RcBrand, i32, i32, i32>::new(|x| x);
let folded = Optic::<ForgetBrand<RcBrand, i32>, _, _, _, _>::evaluate(&g, f);
assert_eq!(folded.run((42, "hi".to_string())), 42);
Source§

impl<PointerBrand: Ord, R: Ord> Ord for ForgetBrand<PointerBrand, R>

Source§

fn cmp(&self, other: &ForgetBrand<PointerBrand, R>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<PointerBrand: PartialEq, R: PartialEq> PartialEq for ForgetBrand<PointerBrand, R>

Source§

fn eq(&self, other: &ForgetBrand<PointerBrand, R>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<PointerBrand: PartialOrd, R: PartialOrd> PartialOrd for ForgetBrand<PointerBrand, R>

Source§

fn partial_cmp(&self, other: &ForgetBrand<PointerBrand, R>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<PointerBrand: ToDynCloneFn + 'static, R: 'static> Profunctor for ForgetBrand<PointerBrand, R>

§Type Parameters
  • PointerBrand: The pointer brand.
  • R: The return type of the function.
Source§

fn dimap<'a, A: 'a, B: 'a, C: 'a, D: 'a>( ab: impl Fn(A) -> B + 'a, _cd: impl Fn(C) -> D + 'a, pbc: <Self as Kind_266801a817966495>::Of<'a, B, C>, ) -> <Self as Kind_266801a817966495>::Of<'a, A, D>

Maps functions over the input and output of the Forget profunctor.

§Type Signature

forall PointerBrand R A B C D. ToDynCloneFn PointerBrand => (A -> B, C -> D, Forget PointerBrand R A B B C) -> Forget PointerBrand R A B A D

§Type Parameters
  • 'a: The lifetime of the functions.
  • A: The source type of the new structure.
  • B: The target type of the new structure.
  • C: The source type of the original structure.
  • D: The target type of the original structure.
§Parameters
  • ab: The function to apply to the input.
  • _cd: The function to apply to the output.
  • pbc: The forget instance to transform.
§Returns

A transformed Forget instance.

§Examples
use fp_library::{
	brands::{
		optics::*,
		*,
	},
	classes::{
		optics::*,
		profunctor::*,
		*,
	},
	types::optics::*,
};

let forget: Forget<RcBrand, usize, String, usize> = Forget::new(|s: String| s.len());

let transformed = <ForgetBrand<RcBrand, usize> as Profunctor>::dimap(
	|s: &str| s.to_string(),
	|s: usize| s,
	forget,
);
assert_eq!(transformed.run("hello"), 5);
Source§

fn map_input<'a, A: 'a, B: 'a, C: 'a>( ab: impl Fn(A) -> B + 'a, pbc: <Self as Kind_266801a817966495>::Of<'a, B, C>, ) -> <Self as Kind_266801a817966495>::Of<'a, A, C>

Maps contravariantly over the first argument. Read more
Source§

fn map_output<'a, A: 'a, B: 'a, C: 'a>( bc: impl Fn(B) -> C + 'a, pab: <Self as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Self as Kind_266801a817966495>::Of<'a, A, C>

Maps covariantly over the second argument. Read more
Source§

impl<PointerBrand: ToDynCloneFn + 'static, R: 'static> Strong for ForgetBrand<PointerBrand, R>

§Type Parameters
  • PointerBrand: The pointer brand.
  • R: The return type of the function.
Source§

fn first<'a, A: 'a, B: 'a, C: 'a>( pab: <Self as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Self as Kind_266801a817966495>::Of<'a, (A, C), (B, C)>

Lifts the Forget profunctor to operate on the first component of a tuple.

§Type Signature

forall PointerBrand R A B C. ToDynCloneFn PointerBrand => Forget PointerBrand R A B A B -> Forget PointerBrand R A B (A, C) (B, C)

§Type Parameters
  • 'a: The lifetime of the functions.
  • A: The type of the first component.
  • B: The type of the second component.
  • C: The target type of the first component.
§Parameters
  • pab: The forget instance to transform.
§Returns

A transformed Forget instance that operates on tuples.

§Examples
use fp_library::{
	brands::{
		optics::*,
		*,
	},
	classes::{
		optics::*,
		profunctor::*,
		*,
	},
	types::optics::*,
};

let forget: Forget<RcBrand, usize, String, usize> = Forget::new(|s: String| s.len());

let transformed = <ForgetBrand<RcBrand, usize> as Strong>::first::<String, usize, i32>(forget);
assert_eq!(transformed.run(("hello".to_string(), 42)), 5);
Source§

fn second<'a, A: 'a, B: 'a, C: 'a>( pab: <Self as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Self as Kind_266801a817966495>::Of<'a, (C, A), (C, B)>

Lift a profunctor to operate on the second component of a pair. Read more
Source§

impl<PointerBrand: ToDynCloneFn + 'static, R: 'static + Monoid + Clone> Wander for ForgetBrand<PointerBrand, R>

§Type Parameters
  • PointerBrand: The pointer brand.
  • R: The return type of the function.
Source§

fn wander<'a, S: 'a, T: 'a, A: 'a, B: 'a + Clone>( traversal: impl TraversalFunc<'a, S, T, A, B> + 'a, pab: <Self as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Self as Kind_266801a817966495>::Of<'a, S, T>

Lifts the Forget profunctor to operate on a structure using a traversal.

§Type Signature

forall PointerBrand R S T A B. (ToDynCloneFn PointerBrand, Monoid R) => (TraversalFunc S T A B, Forget PointerBrand R A B A B) -> Forget PointerBrand R A B S T

§Type Parameters
  • 'a: The lifetime of the functions.
  • 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.
§Parameters
  • traversal: The traversal function.
  • pab: The forget instance to transform.
§Returns

A transformed Forget instance that operates on structures.

§Examples
use fp_library::{
	brands::{
		optics::*,
		*,
	},
	classes::{
		optics::*,
		*,
	},
	types::optics::*,
};

let forget: Forget<RcBrand, String, String, String> = Forget::new(|x: String| x);

// We use a manual implementation for the example to avoid complex trait bounds
let transformed = Forget::<RcBrand, String, Vec<String>, Vec<String>>::new(|v| v.join(""));
assert_eq!(transformed.run(vec!["a".to_string(), "b".to_string()]), "ab".to_string());
Source§

impl<PointerBrand: Copy, R: Copy> Copy for ForgetBrand<PointerBrand, R>

Source§

impl<PointerBrand: Eq, R: Eq> Eq for ForgetBrand<PointerBrand, R>

Source§

impl<PointerBrand, R> StructuralPartialEq for ForgetBrand<PointerBrand, R>

Auto Trait Implementations§

§

impl<PointerBrand, R> Freeze for ForgetBrand<PointerBrand, R>

§

impl<PointerBrand, R> RefUnwindSafe for ForgetBrand<PointerBrand, R>
where PointerBrand: RefUnwindSafe, R: RefUnwindSafe,

§

impl<PointerBrand, R> Send for ForgetBrand<PointerBrand, R>
where PointerBrand: Send, R: Send,

§

impl<PointerBrand, R> Sync for ForgetBrand<PointerBrand, R>
where PointerBrand: Sync, R: Sync,

§

impl<PointerBrand, R> Unpin for ForgetBrand<PointerBrand, R>
where PointerBrand: Unpin, R: Unpin,

§

impl<PointerBrand, R> UnsafeUnpin for ForgetBrand<PointerBrand, R>

§

impl<PointerBrand, R> UnwindSafe for ForgetBrand<PointerBrand, R>
where PointerBrand: UnwindSafe, R: UnwindSafe,

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> Pipe for T

Source§

fn pipe<B>(self, f: impl FnOnce(Self) -> B) -> B

Pipes self into a function, enabling left-to-right composition. 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.