pub struct Ref;Expand description
Marker type indicating the closure receives references.
Selected automatically by the compiler when the closure’s argument
type is &A. Routes to by-reference trait methods
(e.g., RefFunctor::ref_map,
RefSemimonad::ref_bind).
Trait Implementations§
Source§impl<'a, Brand, A> AltDispatch<'a, Brand, A, Ref> for &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
Routes borrowed containers to RefAlt::ref_alt.
impl<'a, Brand, A> AltDispatch<'a, Brand, A, Ref> for &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
Routes borrowed containers to RefAlt::ref_alt.
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the functor.A: The type of the value(s) inside the functor.
Source§fn dispatch(
self,
other: &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn dispatch( self, other: &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
§Type Signature
forall Brand A. RefAlt Brand => (&Brand A, &Brand A) -> Brand A
§Parameters
self: The borrowed container.other: The other borrowed container to combine with.
§Returns
A new container from the combination of both inputs.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let x: Option<i32> = None;
let y = Some(5);
let result = alt::<OptionBrand, _, _, _>(&x, &y);
assert_eq!(result, Some(5));Source§impl<'a, 'b, Brand, A, B> ApplyFirstDispatch<'a, Brand, A, B, Ref> for &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>where
Brand: RefApplyFirst,
A: 'a + Clone,
B: 'a,
'a: 'b,
Routes borrowed containers to RefApplyFirst::ref_apply_first.
impl<'a, 'b, Brand, A, B> ApplyFirstDispatch<'a, Brand, A, B, Ref> for &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>where
Brand: RefApplyFirst,
A: 'a + Clone,
B: 'a,
'a: 'b,
Routes borrowed containers to RefApplyFirst::ref_apply_first.
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the applicative.A: The type of the value(s) inside the first container.B: The type of the value(s) inside the second container.
Source§fn dispatch(self, fb: Self::FB) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn dispatch(self, fb: Self::FB) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
§Type Signature
forall Brand A B. RefApplyFirst Brand => (&Brand A, &Brand B) -> Brand A
§Parameters
self: The borrowed first container.fb: The second borrowed container (its result is discarded).
§Returns
A container preserving the values from the first input.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let a = Some(5);
let b = Some(10);
let result = apply_first::<OptionBrand, _, _, _, _>(&a, &b);
assert_eq!(result, Some(5));Source§type FB = &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
type FB = &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
Source§impl<'a, 'b, Brand, A, B> ApplySecondDispatch<'a, Brand, A, B, Ref> for &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>where
Brand: RefApplySecond,
A: 'a,
B: 'a + Clone,
'a: 'b,
Routes borrowed containers to RefApplySecond::ref_apply_second.
impl<'a, 'b, Brand, A, B> ApplySecondDispatch<'a, Brand, A, B, Ref> for &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>where
Brand: RefApplySecond,
A: 'a,
B: 'a + Clone,
'a: 'b,
Routes borrowed containers to RefApplySecond::ref_apply_second.
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the applicative.A: The type of the value(s) inside the first container.B: The type of the value(s) inside the second container.
Source§fn dispatch(self, fb: Self::FB) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch(self, fb: Self::FB) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. RefApplySecond Brand => (&Brand A, &Brand B) -> Brand B
§Parameters
self: The borrowed first container.fb: The second borrowed container (its result is kept).
§Returns
A container preserving the values from the second input.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let a = Some(5);
let b = Some(10);
let result = apply_second::<OptionBrand, _, _, _, _>(&a, &b);
assert_eq!(result, Some(10));Source§type FB = &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
type FB = &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
Source§impl<'a, 'b, FnBrand, Brand, A, B, C, F, G> BiFoldLeftDispatch<'a, FnBrand, Brand, A, B, C, &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, Ref> for (F, G)
Routes (Fn(C, &A) -> C, Fn(C, &B) -> C) closure tuples to RefBifoldable::ref_bi_fold_left.
impl<'a, 'b, FnBrand, Brand, A, B, C, F, G> BiFoldLeftDispatch<'a, FnBrand, Brand, A, B, C, &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, Ref> for (F, G)
Routes (Fn(C, &A) -> C, Fn(C, &B) -> C) closure tuples to RefBifoldable::ref_bi_fold_left.
The container must be passed by reference (&p).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The bifoldable brand.A: The first element type.B: The second element type.C: The accumulator type.F: The first closure type.G: The second closure type.
Source§fn dispatch(
self,
z: C,
fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>,
) -> C
fn dispatch( self, z: C, fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, ) -> C
§Type Signature
forall Brand A B C. (RefBifoldable Brand, LiftFn FnBrand) => (((C, &A) -> C, (C, &B) -> C), C, &Brand A B) -> C
§Parameters
self: The closure tuple.z: The initial accumulator value.fa: A reference to the structure to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let x: Result<i32, i32> = Ok(5);
let y = bi_fold_left::<RcFnBrand, ResultBrand, _, _, _, _, _>(
(|acc, e: &i32| acc - *e, |acc, s: &i32| acc + *s),
10,
&x,
);
assert_eq!(y, 15);Source§impl<'a, 'b, FnBrand, Brand, A, B, M, F, G> BiFoldMapDispatch<'a, FnBrand, Brand, A, B, M, &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, Ref> for (F, G)
Routes (Fn(&A) -> M, Fn(&B) -> M) closure tuples to RefBifoldable::ref_bi_fold_map.
impl<'a, 'b, FnBrand, Brand, A, B, M, F, G> BiFoldMapDispatch<'a, FnBrand, Brand, A, B, M, &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, Ref> for (F, G)
Routes (Fn(&A) -> M, Fn(&B) -> M) closure tuples to RefBifoldable::ref_bi_fold_map.
The container must be passed by reference (&p).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The bifoldable brand.A: The first element type.B: The second element type.M: The monoid type.F: The first closure type.G: The second closure type.
Source§fn dispatch(self, fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>) -> M
fn dispatch(self, fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>) -> M
§Type Signature
forall Brand A B M. (RefBifoldable Brand, LiftFn FnBrand, Monoid M) => ((&A -> M, &B -> M), &Brand A B) -> M
§Parameters
self: The closure tuple.fa: A reference to the structure to fold.
§Returns
The combined monoid value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let x: Result<i32, i32> = Ok(5);
let y = bi_fold_map::<RcFnBrand, ResultBrand, _, _, _, _, _>(
(|e: &i32| e.to_string(), |s: &i32| s.to_string()),
&x,
);
assert_eq!(y, "5".to_string());Source§impl<'a, 'b, FnBrand, Brand, A, B, C, F, G> BiFoldRightDispatch<'a, FnBrand, Brand, A, B, C, &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, Ref> for (F, G)
Routes (Fn(&A, C) -> C, Fn(&B, C) -> C) closure tuples to RefBifoldable::ref_bi_fold_right.
impl<'a, 'b, FnBrand, Brand, A, B, C, F, G> BiFoldRightDispatch<'a, FnBrand, Brand, A, B, C, &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, Ref> for (F, G)
Routes (Fn(&A, C) -> C, Fn(&B, C) -> C) closure tuples to RefBifoldable::ref_bi_fold_right.
The container must be passed by reference (&p).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The bifoldable brand.A: The first element type.B: The second element type.C: The accumulator type.F: The first closure type.G: The second closure type.
Source§fn dispatch(
self,
z: C,
fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>,
) -> C
fn dispatch( self, z: C, fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, ) -> C
§Type Signature
forall Brand A B C. (RefBifoldable Brand, LiftFn FnBrand) => (((&A, C) -> C, (&B, C) -> C), C, &Brand A B) -> C
§Parameters
self: The closure tuple.z: The initial accumulator value.fa: A reference to the structure to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let x: Result<i32, i32> = Err(3);
let y = bi_fold_right::<RcFnBrand, ResultBrand, _, _, _, _, _>(
(|e: &i32, acc| acc - *e, |s: &i32, acc| acc + *s),
10,
&x,
);
assert_eq!(y, 7);Source§impl<'a, 'b, FnBrand, Brand, A, B, C, D, F, Func1, Func2> BiTraverseDispatch<'a, FnBrand, Brand, A, B, C, D, F, &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, Ref> for (Func1, Func2)where
Brand: RefBitraversable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
C: 'a + Clone,
D: 'a + Clone,
F: Applicative,
Func1: Fn(&A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, C> + 'a,
Func2: Fn(&B) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, D> + 'a,
<Brand as Kind_266801a817966495>::Of<'a, C, D>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, C>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, D>: Clone,
Routes (Fn(&A) -> F::Of<C>, Fn(&B) -> F::Of<D>) closure tuples to RefBitraversable::ref_bi_traverse.
impl<'a, 'b, FnBrand, Brand, A, B, C, D, F, Func1, Func2> BiTraverseDispatch<'a, FnBrand, Brand, A, B, C, D, F, &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, Ref> for (Func1, Func2)where
Brand: RefBitraversable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
C: 'a + Clone,
D: 'a + Clone,
F: Applicative,
Func1: Fn(&A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, C> + 'a,
Func2: Fn(&B) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, D> + 'a,
<Brand as Kind_266801a817966495>::Of<'a, C, D>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, C>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, D>: Clone,
Routes (Fn(&A) -> F::Of<C>, Fn(&B) -> F::Of<D>) closure tuples to RefBitraversable::ref_bi_traverse.
The FnBrand parameter is passed through to the underlying
ref_bi_traverse call.
The container must be passed by reference (&p).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The brand of the bitraversable structure.A: The first input type.B: The second input type.C: The first output type.D: The second output type.F: The applicative functor brand.Func1: The first closure type.Func2: The second closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_266801a817966495>::Of<'a, C, D>>
fn dispatch( self, fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, ) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_266801a817966495>::Of<'a, C, D>>
§Type Signature
forall Brand A B C D F. (RefBitraversable Brand, LiftFn FnBrand, Applicative F) => ((&A -> F C, &B -> F D), &Brand A B) -> F (Brand C D)
§Parameters
self: The closure tuple.fa: A reference to the structure to traverse.
§Returns
The combined result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let x: Result<i32, i32> = Ok(5);
let result = bi_traverse::<RcFnBrand, ResultBrand, _, _, _, _, OptionBrand, _, _>(
(|e: &i32| Some(e + 1), |s: &i32| Some(s * 2)),
&x,
);
assert_eq!(result, Some(Ok(10)));Source§impl<'a, 'b, Brand, A, B, C, D, F, G> BimapDispatch<'a, Brand, A, B, C, D, &'b <Brand as Kind_266801a817966495>::Of<'a, A, C>, Ref> for (F, G)
Routes (Fn(&A) -> B, Fn(&C) -> D) closure tuples to RefBifunctor::ref_bimap.
impl<'a, 'b, Brand, A, B, C, D, F, G> BimapDispatch<'a, Brand, A, B, C, D, &'b <Brand as Kind_266801a817966495>::Of<'a, A, C>, Ref> for (F, G)
Routes (Fn(&A) -> B, Fn(&C) -> D) closure tuples to RefBifunctor::ref_bimap.
The container must be passed by reference (&p).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.Brand: The brand.A: The first input type.B: The first output type.C: The second input type.D: The second output type.F: The first closure type.G: The second closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, C>,
) -> <Brand as Kind_266801a817966495>::Of<'a, B, D>
fn dispatch( self, fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, C>, ) -> <Brand as Kind_266801a817966495>::Of<'a, B, D>
§Type Signature
forall Brand A B C D. RefBifunctor Brand => ((&A -> B, &C -> D), &Brand A C) -> Brand B D
§Parameters
self: The closure tuple.fa: A reference to the bifunctor value.
§Returns
The result of bimapping.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let x = Result::<i32, i32>::Ok(5);
let result = bimap::<ResultBrand, _, _, _, _, _, _>((|e: &i32| *e + 1, |s: &i32| *s * 2), &x);
assert_eq!(result, Ok(10));Source§impl<'a, 'b, Brand, A, B, F> BindDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Fwhere
Brand: RefSemimonad,
A: 'a,
B: 'a,
F: Fn(&A) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
Routes Fn(&A) -> Of<B> closures to RefSemimonad::ref_bind.
impl<'a, 'b, Brand, A, B, F> BindDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Fwhere
Brand: RefSemimonad,
A: 'a,
B: 'a,
F: Fn(&A) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
Routes Fn(&A) -> Of<B> closures to RefSemimonad::ref_bind.
The container must be passed by reference (&ma).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.Brand: The brand.A: The input type.B: The output type.F: The closure type.
Source§fn dispatch(
self,
ma: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, ma: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. RefSemimonad Brand => (&A -> Brand B, &Brand A) -> Brand B
§Parameters
self: The closure that takes references.ma: A reference to the monadic value.
§Returns
The result of binding.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let lazy = RcLazy::pure(5);
let result = bind::<LazyBrand<RcLazyConfig>, _, _, _, _>(&lazy, |x: &i32| {
Lazy::<_, RcLazyConfig>::new({
let v = *x;
move || v * 2
})
});
assert_eq!(*result.evaluate(), 10);Source§impl<P: UnsizedCoercible> CloneFn<Ref> for FnBrand<P>
§Type Parameters
P: The reference-counted pointer type.
impl<P: UnsizedCoercible> CloneFn<Ref> for FnBrand<P>
§Type Parameters
P: The reference-counted pointer type.
Source§type Of<'a, A: 'a, B: 'a> = <P as RefCountedPointer>::CloneableOf<'a, dyn Fn(&A) -> B + 'a>
type Of<'a, A: 'a, B: 'a> = <P as RefCountedPointer>::CloneableOf<'a, dyn Fn(&A) -> B + 'a>
Source§type PointerBrand = P
type PointerBrand = P
Source§impl ClosureMode for Ref
impl ClosureMode for Ref
Source§impl<'a, Brand, A> CompactDispatch<'a, Brand, A, Ref> for &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, <OptionBrand as Kind_cdc7cd43dac7585f>::Of<'a, A>>where
Brand: RefCompactable,
A: 'a + Clone,
Routes borrowed containers to RefCompactable::ref_compact.
impl<'a, Brand, A> CompactDispatch<'a, Brand, A, Ref> for &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, <OptionBrand as Kind_cdc7cd43dac7585f>::Of<'a, A>>where
Brand: RefCompactable,
A: 'a + Clone,
Routes borrowed containers to RefCompactable::ref_compact.
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the compactable.A: The type of the value(s) inside theOptionwrappers.
Source§fn dispatch(self) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn dispatch(self) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
§Type Signature
forall Brand A. RefCompactable Brand => &Brand (Option A) -> Brand A
§Returns
A new container with None values removed and Some values unwrapped.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let v = vec![Some(1), None, Some(3)];
let result = compact::<VecBrand, _, _, _>(&v);
assert_eq!(result, vec![1, 3]);Source§impl<'a, Brand, A, B, C, F, G> ComposeKleisliDispatch<'a, Brand, A, B, C, Ref> for (F, G)where
Brand: RefSemimonad,
A: 'a,
B: 'a,
C: 'a,
F: Fn(&A) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
G: Fn(&B) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C> + 'a,
§Type Parameters
'a: The lifetime of the values.
Brand: The higher-kinded type brand.
A: The input type.
B: The intermediate type.
C: The output type.
F: The first closure type.
G: The second closure type.
impl<'a, Brand, A, B, C, F, G> ComposeKleisliDispatch<'a, Brand, A, B, C, Ref> for (F, G)where
Brand: RefSemimonad,
A: 'a,
B: 'a,
C: 'a,
F: Fn(&A) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
G: Fn(&B) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C> + 'a,
§Type Parameters
'a: The lifetime of the values.Brand: The higher-kinded type brand.A: The input type.B: The intermediate type.C: The output type.F: The first closure type.G: The second closure type.
Source§fn dispatch(self, a: A) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>
fn dispatch(self, a: A) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>
§Type Signature
forall Brand A B C. RefSemimonad Brand => ((&A -> Brand B, &B -> Brand C), A) -> Brand C
§Parameters
self: The closure pair.a: The input value.
§Returns
The composed result.
§Examples
use fp_library::{
brands::*,
functions::*,
types::*,
};
let result = compose_kleisli::<LazyBrand<RcLazyConfig>, _, _, _, _>(
(
|x: &i32| {
let v = *x + 1;
RcLazy::new(move || v)
},
|y: &i32| {
let v = *y * 2;
RcLazy::new(move || v)
},
),
5,
);
assert_eq!(*result.evaluate(), 12);Source§impl<'a, 'b, Brand, A, F> FilterDispatch<'a, Brand, A, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> bool closures to RefFilterable::ref_filter.
impl<'a, 'b, Brand, A, F> FilterDispatch<'a, Brand, A, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> bool closures to RefFilterable::ref_filter.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the filterable.A: The type of the value(s) inside the filterable.F: The closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
§Type Signature
forall Brand A. RefFilterable Brand => (&A -> bool, &Brand A) -> Brand A
§Parameters
self: The closure that takes references.fa: A reference to the filterable instance.
§Returns
A new filterable instance containing only the values for which the predicate returned true.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = filter::<OptionBrand, _, _, _>(|x: &i32| *x > 3, &Some(5));
assert_eq!(result, Some(5));Source§impl<'a, 'b, Brand, A, B, F> FilterMapDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> Option<B> closures to RefFilterable::ref_filter_map.
impl<'a, 'b, Brand, A, B, F> FilterMapDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> Option<B> closures to RefFilterable::ref_filter_map.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the filterable.A: The type of the value(s) inside the filterable.B: The type of the result(s) of applying the function.F: The closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. RefFilterable Brand => (&A -> Option B, &Brand A) -> Brand B
§Parameters
self: The closure that takes references.fa: A reference to the filterable instance.
§Returns
A new filterable instance containing only the values for which the function returned Some.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = filter_map::<OptionBrand, _, _, _, _>(
|x: &i32| if *x > 3 { Some(*x * 2) } else { None },
&Some(5),
);
assert_eq!(result, Some(10));Source§impl<'a, 'b, Brand, A, B, F> FilterMapWithIndexDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A) -> Option<B> closures to RefFilterableWithIndex::ref_filter_map_with_index.
impl<'a, 'b, Brand, A, B, F> FilterMapWithIndexDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A) -> Option<B> closures to RefFilterableWithIndex::ref_filter_map_with_index.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the filterable.A: The type of the value(s) inside the filterable.B: The type of the result(s) of applying the function.F: The closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. RefFilterableWithIndex Brand => ((Index, &A) -> Option B, &Brand A) -> Brand B
§Parameters
self: The closure that takes an index and references.fa: A reference to the filterable instance.
§Returns
A new filterable instance containing only the values for which the function returned Some.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let v = vec![10, 20, 30, 40];
let result = filter_map_with_index::<VecBrand, _, _, _, _>(
|i, x: &i32| if i % 2 == 0 { Some(*x * 2) } else { None },
&v,
);
assert_eq!(result, vec![20, 60]);Source§impl<'a, 'b, Brand, A, F> FilterWithIndexDispatch<'a, Brand, A, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A) -> bool closures to RefFilterableWithIndex::ref_filter_with_index.
impl<'a, 'b, Brand, A, F> FilterWithIndexDispatch<'a, Brand, A, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A) -> bool closures to RefFilterableWithIndex::ref_filter_with_index.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the filterable.A: The type of the value(s) inside the filterable.F: The closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
§Type Signature
forall Brand A. RefFilterableWithIndex Brand => ((Index, &A) -> bool, &Brand A) -> Brand A
§Parameters
self: The closure that takes an index and references.fa: A reference to the filterable instance.
§Returns
A new filterable instance containing only the values for which the predicate returned true.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let v = vec![10, 20, 30, 40];
let result = filter_with_index::<VecBrand, _, _, _>(|i, _x: &i32| i < 2, &v);
assert_eq!(result, vec![10, 20]);Source§impl<'a, 'b, FnBrand, Brand, A, B, F> FoldLeftDispatch<'a, FnBrand, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(B, &A) -> B closures to RefFoldable::ref_fold_left.
impl<'a, 'b, FnBrand, Brand, A, B, F> FoldLeftDispatch<'a, FnBrand, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(B, &A) -> B closures to RefFoldable::ref_fold_left.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The foldable brand.A: The element type.B: The accumulator type.F: The closure type.
Source§fn dispatch(
self,
initial: B,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> B
fn dispatch( self, initial: B, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> B
§Type Signature
forall Brand A B. (RefFoldable Brand, LiftFn FnBrand) => ((B, &A) -> B, B, &Brand A) -> B
§Parameters
self: The closure.initial: The initial accumulator value.fa: A reference to the structure to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let lazy = RcLazy::new(|| 10);
let result =
fold_left::<RcFnBrand, LazyBrand<RcLazyConfig>, _, _, _, _>(|b, a: &i32| b + *a, 5, &lazy);
assert_eq!(result, 15);Source§impl<'a, 'b, FnBrand, Brand, A, B, F> FoldLeftWithIndexDispatch<'a, FnBrand, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, B, &A) -> B closures to RefFoldableWithIndex::ref_fold_left_with_index.
impl<'a, 'b, FnBrand, Brand, A, B, F> FoldLeftWithIndexDispatch<'a, FnBrand, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, B, &A) -> B closures to RefFoldableWithIndex::ref_fold_left_with_index.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The foldable brand.A: The element type.B: The accumulator type.F: The closure type.
Source§fn dispatch(
self,
initial: B,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> B
fn dispatch( self, initial: B, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> B
§Type Signature
forall Brand A B. (RefFoldableWithIndex Brand, LiftFn FnBrand) => ((Index, B, &A) -> B, B, &Brand A) -> B
§Parameters
self: The closure.initial: The initial accumulator value.fa: A reference to the structure to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let lazy = RcLazy::new(|| 10);
let result = fold_left_with_index::<RcFnBrand, LazyBrand<RcLazyConfig>, _, _, _, _>(
|_, acc, x: &i32| acc + *x,
0,
&lazy,
);
assert_eq!(result, 10);Source§impl<'a, 'b, FnBrand, Brand, A, M, F> FoldMapDispatch<'a, FnBrand, Brand, A, M, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> M closures to RefFoldable::ref_fold_map.
impl<'a, 'b, FnBrand, Brand, A, M, F> FoldMapDispatch<'a, FnBrand, Brand, A, M, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> M closures to RefFoldable::ref_fold_map.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The foldable brand.A: The element type.M: The monoid type.F: The closure type.
Source§fn dispatch(self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>) -> M
fn dispatch(self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>) -> M
§Type Signature
forall Brand A M. (RefFoldable Brand, LiftFn FnBrand, Monoid M) => (&A -> M, &Brand A) -> M
§Parameters
self: The closure.fa: A reference to the structure to fold.
§Returns
The combined monoid value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let lazy = RcLazy::new(|| 10);
let result =
fold_map::<RcFnBrand, LazyBrand<RcLazyConfig>, _, _, _, _>(|a: &i32| a.to_string(), &lazy);
assert_eq!(result, "10");Source§impl<'a, 'b, FnBrand, Brand, A, M, F> FoldMapWithIndexDispatch<'a, FnBrand, Brand, A, M, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A) -> M closures to RefFoldableWithIndex::ref_fold_map_with_index.
impl<'a, 'b, FnBrand, Brand, A, M, F> FoldMapWithIndexDispatch<'a, FnBrand, Brand, A, M, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A) -> M closures to RefFoldableWithIndex::ref_fold_map_with_index.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The foldable brand.A: The element type.M: The monoid type.F: The closure type.
Source§fn dispatch(self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>) -> M
fn dispatch(self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>) -> M
§Type Signature
forall Brand A M. (RefFoldableWithIndex Brand, LiftFn FnBrand, Monoid M) => ((Index, &A) -> M, &Brand A) -> M
§Parameters
self: The closure.fa: A reference to the structure to fold.
§Returns
The combined monoid value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let lazy = RcLazy::new(|| 42);
let result = fold_map_with_index::<RcFnBrand, LazyBrand<RcLazyConfig>, _, _, _, _>(
|_, x: &i32| x.to_string(),
&lazy,
);
assert_eq!(result, "42");Source§impl<'a, 'b, FnBrand, Brand, A, B, F> FoldRightDispatch<'a, FnBrand, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A, B) -> B closures to RefFoldable::ref_fold_right.
impl<'a, 'b, FnBrand, Brand, A, B, F> FoldRightDispatch<'a, FnBrand, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A, B) -> B closures to RefFoldable::ref_fold_right.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The foldable brand.A: The element type.B: The accumulator type.F: The closure type.
Source§fn dispatch(
self,
initial: B,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> B
fn dispatch( self, initial: B, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> B
§Type Signature
forall Brand A B. (RefFoldable Brand, LiftFn FnBrand) => ((&A, B) -> B, B, &Brand A) -> B
§Parameters
self: The closure.initial: The initial accumulator value.fa: A reference to the structure to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let lazy = RcLazy::new(|| 10);
let result =
fold_right::<RcFnBrand, LazyBrand<RcLazyConfig>, _, _, _, _>(|a: &i32, b| *a + b, 5, &lazy);
assert_eq!(result, 15);Source§impl<'a, 'b, FnBrand, Brand, A, B, F> FoldRightWithIndexDispatch<'a, FnBrand, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A, B) -> B closures to RefFoldableWithIndex::ref_fold_right_with_index.
impl<'a, 'b, FnBrand, Brand, A, B, F> FoldRightWithIndexDispatch<'a, FnBrand, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A, B) -> B closures to RefFoldableWithIndex::ref_fold_right_with_index.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The foldable brand.A: The element type.B: The accumulator type.F: The closure type.
Source§fn dispatch(
self,
initial: B,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> B
fn dispatch( self, initial: B, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> B
§Type Signature
forall Brand A B. (RefFoldableWithIndex Brand, LiftFn FnBrand) => ((Index, &A, B) -> B, B, &Brand A) -> B
§Parameters
self: The closure.initial: The initial accumulator value.fa: A reference to the structure to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let lazy = RcLazy::new(|| 10);
let result = fold_right_with_index::<RcFnBrand, LazyBrand<RcLazyConfig>, _, _, _, _>(
|_, x: &i32, acc| acc + *x,
0,
&lazy,
);
assert_eq!(result, 10);Source§impl<'a, 'b, Brand, A, B, F> FunctorDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> B closures to RefFunctor::ref_map.
impl<'a, 'b, Brand, A, B, F> FunctorDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> B closures to RefFunctor::ref_map.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the functor.A: The type of the value(s) inside the functor.B: The type of the result(s) of applying the function.F: The closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. RefFunctor Brand => (&A -> B, &Brand A) -> Brand B
§Parameters
self: The closure that takes references.fa: A reference to the functor instance.
§Returns
A new functor instance containing the result(s) of applying the function.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let lazy = RcLazy::pure(10);
let result = map::<LazyBrand<RcLazyConfig>, _, _, _, _>(|x: &i32| *x * 2, &lazy);
assert_eq!(*result.evaluate(), 20);Source§impl<'a, Brand, A> JoinDispatch<'a, Brand, A, Ref> for &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>>
Routes borrowed containers to RefSemimonad::ref_bind with clone.
impl<'a, Brand, A> JoinDispatch<'a, Brand, A, Ref> for &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>>
Routes borrowed containers to RefSemimonad::ref_bind with clone.
§Type Parameters
'a: The lifetime.Brand: The brand.A: The inner element type.
Source§fn dispatch(self) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn dispatch(self) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
Source§impl<'a, 'b, Brand, A, B, C, F> Lift2Dispatch<'a, Brand, A, B, C, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, Ref> for F
Routes Fn(&A, &B) -> C closures to RefLift::ref_lift2.
impl<'a, 'b, Brand, A, B, C, F> Lift2Dispatch<'a, Brand, A, B, C, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, Ref> for F
Routes Fn(&A, &B) -> C closures to RefLift::ref_lift2.
The containers must be passed by reference (&fa, &fb).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.Brand: The brand.A: The first type.B: The second type.C: The result type.F: The closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>
§Type Signature
forall Brand A B C. RefLift Brand => ((&A, &B) -> C, &Brand A, &Brand B) -> Brand C
§Parameters
self: The closure that takes references.fa: A reference to the first context.fb: A reference to the second context.
§Returns
A new context containing the result.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let x = RcLazy::pure(3);
let y = RcLazy::pure(4);
let z = lift2::<LazyBrand<RcLazyConfig>, _, _, _, _, _, _>(|a: &i32, b: &i32| *a + *b, &x, &y);
assert_eq!(*z.evaluate(), 7);Source§impl<'a, 'b, Brand, A, B, C, D, F> Lift3Dispatch<'a, Brand, A, B, C, D, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, Ref> for F
Routes Fn(&A, &B, &C) -> D closures through RefLift::ref_lift2.
impl<'a, 'b, Brand, A, B, C, D, F> Lift3Dispatch<'a, Brand, A, B, C, D, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, Ref> for F
Routes Fn(&A, &B, &C) -> D closures through RefLift::ref_lift2.
The containers must be passed by reference (&fa, &fb, &fc).
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.Brand: The brand.A: First.B: Second.C: Third.D: Result.F: Closure.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>,
fc: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, fc: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>
§Type Signature
forall Brand A B C D. RefLift Brand => ((&A, &B, &C) -> D, &Brand A, &Brand B, &Brand C) -> Brand D
§Parameters
self: The closure that takes references.fa: First context.fb: Second context.fc: Third context.
§Returns
A new context containing the result.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let a = RcLazy::pure(1);
let b = RcLazy::pure(2);
let c = RcLazy::pure(3);
let r = lift3::<LazyBrand<RcLazyConfig>, _, _, _, _, _, _, _, _>(
|a: &i32, b: &i32, c: &i32| *a + *b + *c,
&a,
&b,
&c,
);
assert_eq!(*r.evaluate(), 6);Source§impl<'a, 'b, Brand, A, B, C, D, E, Func> Lift4Dispatch<'a, Brand, A, B, C, D, E, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, Ref> for Func
Routes Fn(&A, &B, &C, &D) -> E closures through RefLift::ref_lift2.
impl<'a, 'b, Brand, A, B, C, D, E, Func> Lift4Dispatch<'a, Brand, A, B, C, D, E, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, Ref> for Func
Routes Fn(&A, &B, &C, &D) -> E closures through RefLift::ref_lift2.
The containers must be passed by reference.
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.Brand: The brand.A: First.B: Second.C: Third.D: Fourth.E: Result.Func: Closure.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>,
fc: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>,
fd: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, fc: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, fd: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>
§Type Signature
forall Brand A B C D E. RefLift Brand => ((&A, &B, &C, &D) -> E, &Brand A, &Brand B, &Brand C, &Brand D) -> Brand E
§Parameters
self: The closure that takes references.fa: First.fb: Second.fc: Third.fd: Fourth.
§Returns
Result context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let a = RcLazy::pure(1);
let b = RcLazy::pure(2);
let c = RcLazy::pure(3);
let d = RcLazy::pure(4);
let r = lift4::<LazyBrand<RcLazyConfig>, _, _, _, _, _, _, _, _, _, _>(
|a: &i32, b: &i32, c: &i32, d: &i32| *a + *b + *c + *d,
&a,
&b,
&c,
&d,
);
assert_eq!(*r.evaluate(), 10);Source§impl<'a, 'b, Brand, A, B, C, D, E, G, Func> Lift5Dispatch<'a, Brand, A, B, C, D, E, G, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, Ref> for Func
Routes Fn(&A, &B, &C, &D, &E) -> G closures through RefLift::ref_lift2.
impl<'a, 'b, Brand, A, B, C, D, E, G, Func> Lift5Dispatch<'a, Brand, A, B, C, D, E, G, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, Ref> for Func
Routes Fn(&A, &B, &C, &D, &E) -> G closures through RefLift::ref_lift2.
The containers must be passed by reference.
§Type Parameters
'a: The lifetime.'b: The borrow lifetime.Brand: The brand.A: 1st.B: 2nd.C: 3rd.D: 4th.E: 5th.G: Result.Func: Closure.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>,
fc: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>,
fd: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>,
fe: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, G>
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, fc: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, fd: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, fe: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, G>
§Type Signature
forall Brand A B C D E G. RefLift Brand => ((&A, &B, &C, &D, &E) -> G, &Brand A, &Brand B, &Brand C, &Brand D, &Brand E) -> Brand G
§Parameters
self: The closure that takes references.fa: 1st.fb: 2nd.fc: 3rd.fd: 4th.fe: 5th.
§Returns
Result context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let a = RcLazy::pure(1);
let b = RcLazy::pure(2);
let c = RcLazy::pure(3);
let d = RcLazy::pure(4);
let e = RcLazy::pure(5);
let r = lift5::<LazyBrand<RcLazyConfig>, _, _, _, _, _, _, _, _, _, _, _, _>(
|a: &i32, b: &i32, c: &i32, d: &i32, e: &i32| *a + *b + *c + *d + *e,
&a,
&b,
&c,
&d,
&e,
);
assert_eq!(*r.evaluate(), 15);Source§impl<'a, 'b, Brand, A, B, F> MapWithIndexDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Fwhere
Brand: RefFunctorWithIndex,
A: 'a,
B: 'a,
Brand::Index: 'a,
F: Fn(Brand::Index, &A) -> B + 'a,
Routes Fn(Brand::Index, &A) -> B closures to RefFunctorWithIndex::ref_map_with_index.
impl<'a, 'b, Brand, A, B, F> MapWithIndexDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Fwhere
Brand: RefFunctorWithIndex,
A: 'a,
B: 'a,
Brand::Index: 'a,
F: Fn(Brand::Index, &A) -> B + 'a,
Routes Fn(Brand::Index, &A) -> B closures to RefFunctorWithIndex::ref_map_with_index.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the functor.A: The type of the value(s) inside the functor.B: The type of the result(s) of applying the function.F: The closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. RefFunctorWithIndex Brand => ((Index, &A) -> B, &Brand A) -> Brand B
§Parameters
self: The closure that takes an index and references.fa: A reference to the functor instance.
§Returns
A new functor instance containing the result(s) of applying the function with index.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let v = vec![10, 20, 30];
let result = map_with_index::<VecBrand, _, _, _, _>(|i, x: &i32| *x + i as i32, &v);
assert_eq!(result, vec![10, 21, 32]);Source§impl<'a, 'b, Brand, A, F> PartitionDispatch<'a, Brand, A, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> bool closures to RefFilterable::ref_partition.
impl<'a, 'b, Brand, A, F> PartitionDispatch<'a, Brand, A, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> bool closures to RefFilterable::ref_partition.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the filterable.A: The type of the value(s) inside the filterable.F: The closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>)
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>)
§Type Signature
forall Brand A. RefFilterable Brand => (&A -> bool, &Brand A) -> (Brand A, Brand A)
§Parameters
self: The closure that takes references.fa: A reference to the filterable instance.
§Returns
A tuple of two filterable instances: the first contains elements satisfying the predicate, the second contains the rest.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let (no, yes) = partition::<OptionBrand, _, _, _>(|x: &i32| *x > 3, &Some(5));
assert_eq!(yes, Some(5));
assert_eq!(no, None);Source§impl<'a, 'b, Brand, A, E, O, F> PartitionMapDispatch<'a, Brand, A, E, O, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> Result<O, E> closures to RefFilterable::ref_partition_map.
impl<'a, 'b, Brand, A, E, O, F> PartitionMapDispatch<'a, Brand, A, E, O, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(&A) -> Result<O, E> closures to RefFilterable::ref_partition_map.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the filterable.A: The type of the value(s) inside the filterable.E: The error type produced by the partitioning function.O: The success type produced by the partitioning function.F: The closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>)
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>)
§Type Signature
forall Brand A E O. RefFilterable Brand => (&A -> Result O E, &Brand A) -> (Brand E, Brand O)
§Parameters
self: The closure that takes references.fa: A reference to the filterable instance.
§Returns
A tuple of two filterable instances: the first contains the Err values, the second contains the Ok values.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let (errs, oks) =
partition_map::<OptionBrand, _, _, _, _, _>(|x: &i32| Ok::<i32, i32>(*x * 2), &Some(5));
assert_eq!(errs, None);
assert_eq!(oks, Some(10));Source§impl<'a, 'b, Brand, A, E, O, F> PartitionMapWithIndexDispatch<'a, Brand, A, E, O, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A) -> Result<O, E> closures to RefFilterableWithIndex::ref_partition_map_with_index.
impl<'a, 'b, Brand, A, E, O, F> PartitionMapWithIndexDispatch<'a, Brand, A, E, O, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A) -> Result<O, E> closures to RefFilterableWithIndex::ref_partition_map_with_index.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the filterable.A: The type of the value(s) inside the filterable.E: The error type produced by the partitioning function.O: The success type produced by the partitioning function.F: The closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>)
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>)
§Type Signature
forall Brand A E O. RefFilterableWithIndex Brand => ((Index, &A) -> Result O E, &Brand A) -> (Brand E, Brand O)
§Parameters
self: The closure that takes an index and references.fa: A reference to the filterable instance.
§Returns
A tuple of two filterable instances: the first contains the Err values, the second contains the Ok values.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let v = vec![10, 20, 30, 40];
let (errs, oks) = partition_map_with_index::<VecBrand, _, _, _, _, _>(
|i, x: &i32| if i < 2 { Ok(*x) } else { Err(*x) },
&v,
);
assert_eq!(oks, vec![10, 20]);
assert_eq!(errs, vec![30, 40]);Source§impl<'a, 'b, Brand, A, F> PartitionWithIndexDispatch<'a, Brand, A, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A) -> bool closures to RefFilterableWithIndex::ref_partition_with_index.
impl<'a, 'b, Brand, A, F> PartitionWithIndexDispatch<'a, Brand, A, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
Routes Fn(Brand::Index, &A) -> bool closures to RefFilterableWithIndex::ref_partition_with_index.
The container must be passed by reference (&fa).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.Brand: The brand of the filterable.A: The type of the value(s) inside the filterable.F: The closure type.
Source§fn dispatch(
self,
fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>)
fn dispatch( self, fa: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>)
§Type Signature
forall Brand A. RefFilterableWithIndex Brand => ((Index, &A) -> bool, &Brand A) -> (Brand A, Brand A)
§Parameters
self: The closure that takes an index and references.fa: A reference to the filterable instance.
§Returns
A tuple of two filterable instances: the first contains elements not satisfying the predicate, the second contains those that do.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let v = vec![10, 20, 30, 40];
let (not_satisfied, satisfied) =
partition_with_index::<VecBrand, _, _, _>(|i, _x: &i32| i < 2, &v);
assert_eq!(satisfied, vec![10, 20]);
assert_eq!(not_satisfied, vec![30, 40]);Source§impl<P: SendUnsizedCoercible> SendCloneFn<Ref> for FnBrand<P>
§Type Parameters
P: The reference-counted pointer type.
impl<P: SendUnsizedCoercible> SendCloneFn<Ref> for FnBrand<P>
§Type Parameters
P: The reference-counted pointer type.
Source§impl<'a, Brand, E, O> SeparateDispatch<'a, Brand, E, O, Ref> for &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>>
Routes borrowed containers to RefCompactable::ref_separate.
impl<'a, Brand, E, O> SeparateDispatch<'a, Brand, E, O, Ref> for &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>>
Routes borrowed containers to RefCompactable::ref_separate.
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the compactable.E: The error type inside theResultwrappers.O: The success type inside theResultwrappers.
Source§fn dispatch(
self,
) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>)
fn dispatch( self, ) -> (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>)
§Type Signature
forall Brand E O. RefCompactable Brand => &Brand (Result O E) -> (Brand E, Brand O)
§Returns
A tuple of two containers: Err values and Ok values.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let v: Vec<Result<i32, i32>> = vec![Ok(1), Err(2), Ok(3)];
let (errs, oks) = separate::<VecBrand, _, _, _, _>(&v);
assert_eq!(oks, vec![1, 3]);
assert_eq!(errs, vec![2]);Source§impl<'a, 'b, FnBrand, Brand, A, B, F, Func> TraverseDispatch<'a, FnBrand, Brand, A, B, F, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Funcwhere
Brand: RefTraversable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
F: Applicative,
Func: Fn(&A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, B>: Clone,
Routes Fn(&A) -> F::Of<B> closures to RefTraversable::ref_traverse.
impl<'a, 'b, FnBrand, Brand, A, B, F, Func> TraverseDispatch<'a, FnBrand, Brand, A, B, F, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Funcwhere
Brand: RefTraversable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
F: Applicative,
Func: Fn(&A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, B>: Clone,
Routes Fn(&A) -> F::Of<B> closures to RefTraversable::ref_traverse.
The FnBrand parameter is passed through to the underlying
ref_traverse call, allowing callers
to choose between RcFnBrand and
ArcFnBrand.
The container must be passed by reference (&ta).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The brand of the traversable structure.A: The type of the elements in the input structure.B: The type of the elements in the output structure.F: The applicative functor brand.Func: The closure type.
Source§fn dispatch(
self,
ta: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>
fn dispatch( self, ta: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>
§Type Signature
forall Brand A B F. (RefTraversable Brand, LiftFn FnBrand, Applicative F) => (&A -> F B, &Brand A) -> F (Brand B)
§Parameters
self: The closure that takes references.ta: A reference to the structure to traverse.
§Returns
The combined result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = traverse::<RcFnBrand, OptionBrand, _, _, OptionBrand, _, _>(
|x: &i32| Some(*x * 2),
&Some(5),
);
assert_eq!(result, Some(Some(10)));Source§impl<'a, 'b, FnBrand, Brand, A, B, F, Func> TraverseWithIndexDispatch<'a, FnBrand, Brand, A, B, F, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Funcwhere
Brand: RefTraversableWithIndex,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
F: Applicative,
Func: Fn(Brand::Index, &A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, B>: Clone,
Brand::Index: 'a,
Routes Fn(Brand::Index, &A) -> F::Of<B> closures to RefTraversableWithIndex::ref_traverse_with_index.
impl<'a, 'b, FnBrand, Brand, A, B, F, Func> TraverseWithIndexDispatch<'a, FnBrand, Brand, A, B, F, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Funcwhere
Brand: RefTraversableWithIndex,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
F: Applicative,
Func: Fn(Brand::Index, &A) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, B> + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>: Clone,
<F as Kind_cdc7cd43dac7585f>::Of<'a, B>: Clone,
Brand::Index: 'a,
Routes Fn(Brand::Index, &A) -> F::Of<B> closures to RefTraversableWithIndex::ref_traverse_with_index.
The FnBrand parameter is accepted for uniformity with TraverseDispatch,
but is not passed through to the underlying
ref_traverse_with_index call.
The container must be passed by reference (&ta).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The brand of the traversable structure.A: The type of the elements in the input structure.B: The type of the elements in the output structure.F: The applicative functor brand.Func: The closure type.
Source§fn dispatch(
self,
ta: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>
fn dispatch( self, ta: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>
§Type Signature
forall Brand A B F. (RefTraversableWithIndex Brand, LiftFn FnBrand, Applicative F) => ((Index, &A) -> F B, &Brand A) -> F (Brand B)
§Parameters
self: The closure that takes an index and references.ta: A reference to the structure to traverse.
§Returns
The combined result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let v = vec![1, 2, 3];
let result = traverse_with_index::<RcFnBrand, VecBrand, _, _, OptionBrand, _, _>(
|_i, x: &i32| Some(*x * 2),
&v,
);
assert_eq!(result, Some(vec![2, 4, 6]));Source§impl<'a, 'b, FnBrand, Brand, M, A, E, O, Func> WiltDispatch<'a, FnBrand, Brand, M, A, E, O, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Funcwhere
Brand: RefWitherable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
E: 'a + Clone,
O: 'a + Clone,
M: Applicative,
Func: Fn(&A) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>> + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>>: Clone,
<M as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>>: Clone,
Routes Fn(&A) -> M::Of<Result<O, E>> closures to RefWitherable::ref_wilt.
impl<'a, 'b, FnBrand, Brand, M, A, E, O, Func> WiltDispatch<'a, FnBrand, Brand, M, A, E, O, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Funcwhere
Brand: RefWitherable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
E: 'a + Clone,
O: 'a + Clone,
M: Applicative,
Func: Fn(&A) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>> + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>>: Clone,
<M as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>>: Clone,
Routes Fn(&A) -> M::Of<Result<O, E>> closures to RefWitherable::ref_wilt.
The container must be passed by reference (&ta).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The brand of the witherable structure.M: The applicative functor brand.A: The type of the elements in the input structure.E: The error type.O: The success type.Func: The closure type.
Source§fn dispatch(
self,
ta: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>)>
fn dispatch( self, ta: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, (<Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, O>)>
§Type Signature
forall Brand M A E O. (RefWitherable Brand, LiftFn FnBrand, Applicative M) => (&A -> M (Result O E), &Brand A) -> M (Brand E, Brand O)
§Parameters
self: The closure that takes references.ta: A reference to the structure to partition.
§Returns
The partitioned result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let v = vec![1, 2, 3, 4, 5];
let result: Option<(Vec<i32>, Vec<i32>)> =
wilt::<RcFnBrand, VecBrand, OptionBrand, _, _, _, _, _>(
|x: &i32| Some(if *x > 3 { Ok(*x) } else { Err(*x) }),
&v,
);
assert_eq!(result, Some((vec![1, 2, 3], vec![4, 5])));Source§impl<'a, 'b, FnBrand, Brand, M, A, B, Func> WitherDispatch<'a, FnBrand, Brand, M, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Funcwhere
Brand: RefWitherable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
M: Applicative,
Func: Fn(&A) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>> + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>>: Clone,
<M as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>>: Clone,
Routes Fn(&A) -> M::Of<Option<B>> closures to RefWitherable::ref_wither.
impl<'a, 'b, FnBrand, Brand, M, A, B, Func> WitherDispatch<'a, FnBrand, Brand, M, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for Funcwhere
Brand: RefWitherable,
FnBrand: LiftFn + 'a,
A: 'a + Clone,
B: 'a + Clone,
M: Applicative,
Func: Fn(&A) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>> + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>>: Clone,
<M as Kind_cdc7cd43dac7585f>::Of<'a, Option<B>>: Clone,
Routes Fn(&A) -> M::Of<Option<B>> closures to RefWitherable::ref_wither.
The container must be passed by reference (&ta).
§Type Parameters
'a: The lifetime of the values.'b: The borrow lifetime.FnBrand: The cloneable function brand.Brand: The brand of the witherable structure.M: The applicative functor brand.A: The type of the elements in the input structure.B: The type of the elements in the output structure.Func: The closure type.
Source§fn dispatch(
self,
ta: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>
fn dispatch( self, ta: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>
§Type Signature
forall Brand M A B. (RefWitherable Brand, LiftFn FnBrand, Applicative M) => (&A -> M (Option B), &Brand A) -> M (Brand B)
§Parameters
self: The closure that takes references.ta: A reference to the structure to filter.
§Returns
The filtered result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let v = vec![1, 2, 3, 4, 5];
let result: Option<Vec<i32>> = wither::<RcFnBrand, VecBrand, OptionBrand, _, _, _, _>(
|x: &i32| if *x > 3 { Some(Some(*x)) } else { Some(None) },
&v,
);
assert_eq!(result, Some(vec![4, 5]));Auto Trait Implementations§
impl Freeze for Ref
impl RefUnwindSafe for Ref
impl Send for Ref
impl Sync for Ref
impl Unpin for Ref
impl UnsafeUnpin for Ref
impl UnwindSafe for Ref
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> 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