pub struct ForgetBrand<PointerBrand, R>(/* private fields */);Expand description
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.
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>>
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>>
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>
impl<PointerBrand: Clone, R: Clone> Clone for ForgetBrand<PointerBrand, R>
Source§fn clone(&self) -> ForgetBrand<PointerBrand, R>
fn clone(&self) -> ForgetBrand<PointerBrand, R>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<PointerBrand: ToDynCloneFn + 'static, R: 'static> Cochoice for ForgetBrand<PointerBrand, R>
§Type Parameters
PointerBrand: The pointer brand.
R: The return type of the function.
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>
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>
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: Default, R: Default> Default for ForgetBrand<PointerBrand, R>
impl<PointerBrand: Default, R: Default> Default for ForgetBrand<PointerBrand, R>
Source§fn default() -> ForgetBrand<PointerBrand, R>
fn default() -> ForgetBrand<PointerBrand, R>
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.
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>
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.
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>
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.
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>
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.
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>
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.
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>
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.
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>
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 >.
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§impl<PointerBrand: ToDynCloneFn + 'static, R: 'static> Kind_266801a817966495 for ForgetBrand<PointerBrand, R>
Generated implementation of Kind_266801a817966495 for ForgetBrand < PointerBrand, R >.
impl<PointerBrand: ToDynCloneFn + 'static, R: 'static> Kind_266801a817966495 for ForgetBrand<PointerBrand, R>
Generated implementation of Kind_266801a817966495 for ForgetBrand < PointerBrand, R >.
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.
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>
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.
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>
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>
impl<PointerBrand: Ord, R: Ord> Ord for ForgetBrand<PointerBrand, R>
Source§fn cmp(&self, other: &ForgetBrand<PointerBrand, R>) -> Ordering
fn cmp(&self, other: &ForgetBrand<PointerBrand, R>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<PointerBrand: PartialEq, R: PartialEq> PartialEq for ForgetBrand<PointerBrand, R>
impl<PointerBrand: PartialEq, R: PartialEq> PartialEq for ForgetBrand<PointerBrand, R>
Source§fn eq(&self, other: &ForgetBrand<PointerBrand, R>) -> bool
fn eq(&self, other: &ForgetBrand<PointerBrand, R>) -> bool
self and other values to be equal, and is used by ==.Source§impl<PointerBrand: PartialOrd, R: PartialOrd> PartialOrd for ForgetBrand<PointerBrand, R>
impl<PointerBrand: PartialOrd, R: PartialOrd> PartialOrd for ForgetBrand<PointerBrand, R>
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.
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>
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>
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>
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>
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>
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.
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)>
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)>
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)>
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.
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>
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());impl<PointerBrand: Copy, R: Copy> Copy for ForgetBrand<PointerBrand, R>
impl<PointerBrand: Eq, R: Eq> Eq for ForgetBrand<PointerBrand, R>
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>
impl<PointerBrand, R> Sync for ForgetBrand<PointerBrand, R>
impl<PointerBrand, R> Unpin for ForgetBrand<PointerBrand, R>
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> 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