pub struct Val;Expand description
Marker type indicating the closure receives owned values.
Selected automatically by the compiler when the closure’s argument
type is A (not &A). Routes to by-value trait methods
(e.g., Functor::map,
Semimonad::bind).
Trait Implementations§
Source§impl<'a, Brand, A> AltDispatch<'a, Brand, A, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
Routes owned containers to Alt::alt.
impl<'a, Brand, A> AltDispatch<'a, Brand, A, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
Routes owned containers to Alt::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. Alt Brand => (Brand A, Brand A) -> Brand A
§Parameters
self: The owned container.other: The other container to combine with.
§Returns
A new container from the combination of both inputs.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = alt::<OptionBrand, _, _, _>(None, Some(5));
assert_eq!(result, Some(5));Source§impl<'a, FnBrand, Brand, A, B, WrappedFn> ApplyDispatch<'a, FnBrand, Brand, A, B, WrappedFn, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, WrappedFn>where
FnBrand: CloneFn + 'a,
Brand: Semiapplicative,
A: Clone + 'a,
B: 'a,
WrappedFn: Clone + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, WrappedFn>: Into<<Brand as Kind_cdc7cd43dac7585f>::Of<'a, <FnBrand as CloneFn>::Of<'a, A, B>>>,
Routes owned containers to Semiapplicative::apply.
impl<'a, FnBrand, Brand, A, B, WrappedFn> ApplyDispatch<'a, FnBrand, Brand, A, B, WrappedFn, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, WrappedFn>where
FnBrand: CloneFn + 'a,
Brand: Semiapplicative,
A: Clone + 'a,
B: 'a,
WrappedFn: Clone + 'a,
<Brand as Kind_cdc7cd43dac7585f>::Of<'a, WrappedFn>: Into<<Brand as Kind_cdc7cd43dac7585f>::Of<'a, <FnBrand as CloneFn>::Of<'a, A, B>>>,
Routes owned containers to Semiapplicative::apply.
§Type Parameters
'a: The lifetime of the values.FnBrand: The function-wrapping brand.Brand: The brand of the applicative.A: The type of the value(s) inside the value container.B: The result type after applying the function.WrappedFn: The concrete wrapped-function type.
Source§fn dispatch(
self,
fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B WrappedFn. (CloneFn FnBrand, Semiapplicative Brand, Into Brand WrappedFn) => (Brand WrappedFn, Brand A) -> Brand B
§Parameters
self: The owned function container.fa: The value container to apply the function(s) to.
§Returns
A new container with the function(s) applied to the value(s).
§Examples
use fp_library::{
brands::*,
classes::*,
functions::*,
};
let f = Some(lift_fn_new::<RcFnBrand, _, _>(|x: i32| x * 2));
let y: Option<i32> = apply(f, Some(5));
assert_eq!(y, Some(10));Source§impl<'a, Brand, A, B> ApplyFirstDispatch<'a, Brand, A, B, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
Routes owned containers to ApplyFirst::apply_first.
impl<'a, Brand, A, B> ApplyFirstDispatch<'a, Brand, A, B, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
Routes owned containers to ApplyFirst::apply_first.
§Type Parameters
'a: The lifetime of the values.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. ApplyFirst Brand => (Brand A, Brand B) -> Brand A
§Parameters
self: The owned first container.fb: The second container (its result is discarded).
§Returns
A container preserving the values from the first input.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = apply_first::<OptionBrand, _, _, _, _>(Some(5), Some(10));
assert_eq!(result, Some(5));Source§type FB = <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
type FB = <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
Source§impl<'a, Brand, A, B> ApplySecondDispatch<'a, Brand, A, B, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
Routes owned containers to ApplySecond::apply_second.
impl<'a, Brand, A, B> ApplySecondDispatch<'a, Brand, A, B, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
Routes owned containers to ApplySecond::apply_second.
§Type Parameters
'a: The lifetime of the values.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. ApplySecond Brand => (Brand A, Brand B) -> Brand B
§Parameters
self: The owned first container.fb: The second container (its result is kept).
§Returns
A container preserving the values from the second input.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = apply_second::<OptionBrand, _, _, _, _>(Some(5), Some(10));
assert_eq!(result, Some(10));Source§type FB = <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
type FB = <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
Source§impl<'a, FnBrand, Brand, A, B, C, F, G> BiFoldLeftDispatch<'a, FnBrand, Brand, A, B, C, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for (F, G)
Routes (Fn(C, A) -> C, Fn(C, B) -> C) closure tuples to Bifoldable::bi_fold_left.
impl<'a, FnBrand, Brand, A, B, C, F, G> BiFoldLeftDispatch<'a, FnBrand, Brand, A, B, C, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for (F, G)
Routes (Fn(C, A) -> C, Fn(C, B) -> C) closure tuples to Bifoldable::bi_fold_left.
§Type Parameters
'a: The 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: <Brand as Kind_266801a817966495>::Of<'a, A, B>) -> C
fn dispatch(self, z: C, fa: <Brand as Kind_266801a817966495>::Of<'a, A, B>) -> C
§Type Signature
forall Brand A B C. Bifoldable Brand => (((C, A) -> C, (C, B) -> C), C, Brand A B) -> C
§Parameters
self: The closure tuple.z: The initial accumulator value.fa: 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| acc - e, |acc, s| acc + s),
10,
x,
);
assert_eq!(y, 15);Source§impl<'a, FnBrand, Brand, A, B, M, F, G> BiFoldMapDispatch<'a, FnBrand, Brand, A, B, M, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for (F, G)
Routes (Fn(A) -> M, Fn(B) -> M) closure tuples to Bifoldable::bi_fold_map.
impl<'a, FnBrand, Brand, A, B, M, F, G> BiFoldMapDispatch<'a, FnBrand, Brand, A, B, M, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for (F, G)
Routes (Fn(A) -> M, Fn(B) -> M) closure tuples to Bifoldable::bi_fold_map.
§Type Parameters
'a: The 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: <Brand as Kind_266801a817966495>::Of<'a, A, B>) -> M
fn dispatch(self, fa: <Brand as Kind_266801a817966495>::Of<'a, A, B>) -> M
§Type Signature
forall Brand A B M. (Bifoldable Brand, Monoid M) => ((A -> M, B -> M), Brand A B) -> M
§Parameters
self: The closure tuple.fa: 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, FnBrand, Brand, A, B, C, F, G> BiFoldRightDispatch<'a, FnBrand, Brand, A, B, C, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for (F, G)
Routes (Fn(A, C) -> C, Fn(B, C) -> C) closure tuples to Bifoldable::bi_fold_right.
impl<'a, FnBrand, Brand, A, B, C, F, G> BiFoldRightDispatch<'a, FnBrand, Brand, A, B, C, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for (F, G)
Routes (Fn(A, C) -> C, Fn(B, C) -> C) closure tuples to Bifoldable::bi_fold_right.
§Type Parameters
'a: The 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: <Brand as Kind_266801a817966495>::Of<'a, A, B>) -> C
fn dispatch(self, z: C, fa: <Brand as Kind_266801a817966495>::Of<'a, A, B>) -> C
§Type Signature
forall Brand A B C. Bifoldable Brand => (((A, C) -> C, (B, C) -> C), C, Brand A B) -> C
§Parameters
self: The closure tuple.z: The initial accumulator value.fa: 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, acc| acc - e, |s, acc| acc + s),
10,
x,
);
assert_eq!(y, 7);Source§impl<'a, FnBrand, Brand, A, B, C, D, F, Func1, Func2> BiTraverseDispatch<'a, FnBrand, Brand, A, B, C, D, F, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for (Func1, Func2)where
Brand: Bitraversable,
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,
Routes (Fn(A) -> F::Of<C>, Fn(B) -> F::Of<D>) closure tuples to Bitraversable::bi_traverse.
impl<'a, FnBrand, Brand, A, B, C, D, F, Func1, Func2> BiTraverseDispatch<'a, FnBrand, Brand, A, B, C, D, F, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for (Func1, Func2)where
Brand: Bitraversable,
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,
Routes (Fn(A) -> F::Of<C>, Fn(B) -> F::Of<D>) closure tuples to Bitraversable::bi_traverse.
The FnBrand parameter is unused by the Val path but is accepted for
uniformity with the Ref path.
§Type Parameters
'a: The lifetime of the values.FnBrand: The cloneable function brand (unused by Val path).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: <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: <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. (Bitraversable Brand, Applicative F) => ((A -> F C, B -> F D), Brand A B) -> F (Brand C D)
§Parameters
self: The closure tuple.fa: 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, Brand, A, B, C, D, F, G> BimapDispatch<'a, Brand, A, B, C, D, <Brand as Kind_266801a817966495>::Of<'a, A, C>, Val> for (F, G)
Routes (Fn(A) -> B, Fn(C) -> D) closure tuples to Bifunctor::bimap.
impl<'a, Brand, A, B, C, D, F, G> BimapDispatch<'a, Brand, A, B, C, D, <Brand as Kind_266801a817966495>::Of<'a, A, C>, Val> for (F, G)
Routes (Fn(A) -> B, Fn(C) -> D) closure tuples to Bifunctor::bimap.
§Type Parameters
'a: The 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: <Brand as Kind_266801a817966495>::Of<'a, A, C>,
) -> <Brand as Kind_266801a817966495>::Of<'a, B, D>
fn dispatch( self, fa: <Brand as Kind_266801a817966495>::Of<'a, A, C>, ) -> <Brand as Kind_266801a817966495>::Of<'a, B, D>
§Type Signature
forall Brand A B C D. Bifunctor Brand => ((A -> B, C -> D), Brand A C) -> Brand B D
§Parameters
self: The closure tuple.fa: The bifunctor value.
§Returns
The result of bimapping.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result =
bimap::<ResultBrand, _, _, _, _, _, _>((|e| e + 1, |s: i32| s * 2), Ok::<i32, i32>(5));
assert_eq!(result, Ok(10));Source§impl<'a, Brand, A, B, F> BindDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> Of<B> closures to Semimonad::bind.
impl<'a, Brand, A, B, F> BindDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> Of<B> closures to Semimonad::bind.
§Type Parameters
'a: The lifetime.Brand: The brand.A: The input type.B: The output type.F: The closure type.
Source§fn dispatch(
self,
ma: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, ma: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. Semimonad Brand => (A -> Brand B, Brand A) -> Brand B
§Parameters
self: The closure that takes owned values.ma: The monadic value.
§Returns
The result of binding.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = bind::<OptionBrand, _, _, _, _>(Some(5), |x: i32| Some(x * 2));
assert_eq!(result, Some(10));Source§impl ClosureMode for Val
impl ClosureMode for Val
Source§impl<'a, Brand, A> CompactDispatch<'a, Brand, A, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, <OptionBrand as Kind_cdc7cd43dac7585f>::Of<'a, A>>where
Brand: Compactable,
A: 'a,
Routes owned containers to Compactable::compact.
impl<'a, Brand, A> CompactDispatch<'a, Brand, A, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, <OptionBrand as Kind_cdc7cd43dac7585f>::Of<'a, A>>where
Brand: Compactable,
A: 'a,
Routes owned containers to Compactable::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. Compactable 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 result = compact::<VecBrand, _, _, _>(vec![Some(1), None, Some(3)]);
assert_eq!(result, vec![1, 3]);Source§impl<'a, Brand, A, B, C, F, G> ComposeKleisliDispatch<'a, Brand, A, B, C, Val> for (F, G)where
Brand: Semimonad,
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, Val> for (F, G)where
Brand: Semimonad,
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. Semimonad 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::*,
};
let result =
compose_kleisli::<OptionBrand, _, _, _, _>((|x: i32| Some(x + 1), |y: i32| Some(y * 2)), 5);
assert_eq!(result, Some(12));Source§impl<'a, Brand, A, B, F> ContravariantDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Fwhere
Brand: Contravariant,
A: 'a,
B: 'a,
F: Fn(B) -> A + 'a,
Routes Fn(B) -> A closures to Contravariant::contramap.
impl<'a, Brand, A, B, F> ContravariantDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Fwhere
Brand: Contravariant,
A: 'a,
B: 'a,
F: Fn(B) -> A + 'a,
Routes Fn(B) -> A closures to Contravariant::contramap.
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the contravariant functor.A: The type of the value(s) inside the contravariant functor.B: The type that the new contravariant functor accepts.F: The closure type.
Source§fn dispatch(
self,
fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. Contravariant Brand => (B -> A, Brand A) -> Brand B
§Parameters
self: The closure that maps the new input type to the original.fa: The contravariant functor instance.
§Returns
A new contravariant functor that accepts values of type B.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let f = std::rc::Rc::new(|x: i32| x + 1) as std::rc::Rc<dyn Fn(i32) -> i32>;
let g =
contramap::<ProfunctorSecondAppliedBrand<RcFnBrand, i32>, _, _, _, _>(|x: i32| x * 2, f);
assert_eq!(g(5), 11);Source§impl<'a, Brand, A, F> FilterDispatch<'a, Brand, A, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> bool closures to Filterable::filter.
impl<'a, Brand, A, F> FilterDispatch<'a, Brand, A, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> bool closures to Filterable::filter.
§Type Parameters
'a: The lifetime of the values.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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
§Type Signature
forall Brand A. Filterable Brand => (A -> bool, Brand A) -> Brand A
§Parameters
self: The closure that takes owned values.fa: The filterable instance containing the value(s).
§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, Brand, A, B, F> FilterMapDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> Option<B> closures to Filterable::filter_map.
impl<'a, Brand, A, B, F> FilterMapDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> Option<B> closures to Filterable::filter_map.
§Type Parameters
'a: The lifetime of the values.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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. Filterable Brand => (A -> Option B, Brand A) -> Brand B
§Parameters
self: The closure that takes owned values.fa: The filterable instance containing the value(s).
§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, Brand, A, B, F> FilterMapWithIndexDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Fwhere
Brand: FilterableWithIndex,
A: 'a,
B: 'a,
Brand::Index: 'a,
F: Fn(Brand::Index, A) -> Option<B> + 'a,
Routes Fn(Brand::Index, A) -> Option<B> closures to FilterableWithIndex::filter_map_with_index.
impl<'a, Brand, A, B, F> FilterMapWithIndexDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Fwhere
Brand: FilterableWithIndex,
A: 'a,
B: 'a,
Brand::Index: 'a,
F: Fn(Brand::Index, A) -> Option<B> + 'a,
Routes Fn(Brand::Index, A) -> Option<B> closures to FilterableWithIndex::filter_map_with_index.
§Type Parameters
'a: The lifetime of the values.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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. FilterableWithIndex Brand => ((Index, A) -> Option B, Brand A) -> Brand B
§Parameters
self: The closure that takes an index and owned values.fa: The filterable instance containing the value(s).
§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_with_index::<VecBrand, _, _, _, _>(
|i, x: i32| if i % 2 == 0 { Some(x * 2) } else { None },
vec![10, 20, 30, 40],
);
assert_eq!(result, vec![20, 60]);Source§impl<'a, Brand, A, F> FilterWithIndexDispatch<'a, Brand, A, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, A) -> bool closures to FilterableWithIndex::filter_with_index.
impl<'a, Brand, A, F> FilterWithIndexDispatch<'a, Brand, A, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, A) -> bool closures to FilterableWithIndex::filter_with_index.
§Type Parameters
'a: The lifetime of the values.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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>
§Type Signature
forall Brand A. FilterableWithIndex Brand => ((Index, A) -> bool, Brand A) -> Brand A
§Parameters
self: The closure that takes an index and owned values.fa: The filterable instance containing the value(s).
§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_with_index::<VecBrand, _, _, _>(|i, _x: i32| i < 2, vec![10, 20, 30, 40]);
assert_eq!(result, vec![10, 20]);Source§impl<'a, FnBrand, Brand, A, B, F> FoldLeftDispatch<'a, FnBrand, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(B, A) -> B closures to Foldable::fold_left.
impl<'a, FnBrand, Brand, A, B, F> FoldLeftDispatch<'a, FnBrand, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(B, A) -> B closures to Foldable::fold_left.
§Type Parameters
'a: The 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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> B
fn dispatch( self, initial: B, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> B
§Type Signature
forall Brand A B. Foldable Brand => ((B, A) -> B, B, Brand A) -> B
§Parameters
self: The closure.initial: The initial accumulator value.fa: The structure to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = fold_left::<RcFnBrand, VecBrand, _, _, _, _>(|b, a| b + a, 0, vec![1, 2, 3]);
assert_eq!(result, 6);Source§impl<'a, FnBrand, Brand, A, B, F> FoldLeftWithIndexDispatch<'a, FnBrand, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, B, A) -> B closures to FoldableWithIndex::fold_left_with_index.
impl<'a, FnBrand, Brand, A, B, F> FoldLeftWithIndexDispatch<'a, FnBrand, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, B, A) -> B closures to FoldableWithIndex::fold_left_with_index.
§Type Parameters
'a: The 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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> B
fn dispatch( self, initial: B, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> B
§Type Signature
forall Brand A B. FoldableWithIndex Brand => ((Index, B, A) -> B, B, Brand A) -> B
§Parameters
self: The closure.initial: The initial accumulator value.fa: The structure to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = fold_left_with_index::<RcFnBrand, VecBrand, _, _, _, _>(
|i, acc: String, x: i32| format!("{acc}{i}:{x},"),
String::new(),
vec![10, 20, 30],
);
assert_eq!(result, "0:10,1:20,2:30,");Source§impl<'a, FnBrand, Brand, A, M, F> FoldMapDispatch<'a, FnBrand, Brand, A, M, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> M closures to Foldable::fold_map.
impl<'a, FnBrand, Brand, A, M, F> FoldMapDispatch<'a, FnBrand, Brand, A, M, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> M closures to Foldable::fold_map.
§Type Parameters
'a: The 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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>) -> M
fn dispatch(self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>) -> M
§Type Signature
forall Brand A M. (Foldable Brand, Monoid M) => (A -> M, Brand A) -> M
§Parameters
self: The closure.fa: The structure to fold.
§Returns
The combined monoid value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = fold_map::<RcFnBrand, VecBrand, _, _, _, _>(|a: i32| a.to_string(), vec![1, 2, 3]);
assert_eq!(result, "123");Source§impl<'a, FnBrand, Brand, A, M, F> FoldMapWithIndexDispatch<'a, FnBrand, Brand, A, M, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, A) -> M closures to FoldableWithIndex::fold_map_with_index.
impl<'a, FnBrand, Brand, A, M, F> FoldMapWithIndexDispatch<'a, FnBrand, Brand, A, M, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, A) -> M closures to FoldableWithIndex::fold_map_with_index.
§Type Parameters
'a: The 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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>) -> M
fn dispatch(self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>) -> M
§Type Signature
forall Brand A M. (FoldableWithIndex Brand, Monoid M) => ((Index, A) -> M, Brand A) -> M
§Parameters
self: The closure.fa: The structure to fold.
§Returns
The combined monoid value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = fold_map_with_index::<RcFnBrand, VecBrand, _, _, _, _>(
|i, x: i32| format!("{i}:{x}"),
vec![10, 20, 30],
);
assert_eq!(result, "0:101:202:30");Source§impl<'a, FnBrand, Brand, A, B, F> FoldRightDispatch<'a, FnBrand, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A, B) -> B closures to Foldable::fold_right.
impl<'a, FnBrand, Brand, A, B, F> FoldRightDispatch<'a, FnBrand, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A, B) -> B closures to Foldable::fold_right.
§Type Parameters
'a: The 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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> B
fn dispatch( self, initial: B, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> B
§Type Signature
forall Brand A B. Foldable Brand => ((A, B) -> B, B, Brand A) -> B
§Parameters
self: The closure.initial: The initial accumulator value.fa: The structure to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = fold_right::<RcFnBrand, VecBrand, _, _, _, _>(|a, b| a + b, 0, vec![1, 2, 3]);
assert_eq!(result, 6);Source§impl<'a, FnBrand, Brand, A, B, F> FoldRightWithIndexDispatch<'a, FnBrand, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, A, B) -> B closures to FoldableWithIndex::fold_right_with_index.
impl<'a, FnBrand, Brand, A, B, F> FoldRightWithIndexDispatch<'a, FnBrand, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, A, B) -> B closures to FoldableWithIndex::fold_right_with_index.
§Type Parameters
'a: The 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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> B
fn dispatch( self, initial: B, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> B
§Type Signature
forall Brand A B. FoldableWithIndex Brand => ((Index, A, B) -> B, B, Brand A) -> B
§Parameters
self: The closure.initial: The initial accumulator value.fa: The structure to fold.
§Returns
The final accumulator value.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = fold_right_with_index::<RcFnBrand, VecBrand, _, _, _, _>(
|i, x: i32, acc: String| format!("{acc}{i}:{x},"),
String::new(),
vec![10, 20, 30],
);
assert_eq!(result, "2:30,1:20,0:10,");Source§impl<'a, Brand, A, B, F> FunctorDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> B closures to Functor::map.
impl<'a, Brand, A, B, F> FunctorDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> B closures to Functor::map.
§Type Parameters
'a: The lifetime of the values.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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. Functor Brand => (A -> B, Brand A) -> Brand B
§Parameters
self: The closure that takes owned values.fa: The functor instance containing the value(s).
§Returns
A new functor instance containing the result(s) of applying the function.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = map::<OptionBrand, _, _, _, _>(|x: i32| x * 2, Some(5));
assert_eq!(result, Some(10));Source§impl<'a, Brand, A> JoinDispatch<'a, Brand, A, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>>where
Brand: Semimonad,
A: 'a,
Routes owned containers to Semimonad::bind with identity.
impl<'a, Brand, A> JoinDispatch<'a, Brand, A, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>>where
Brand: Semimonad,
A: 'a,
Routes owned containers to Semimonad::bind with identity.
§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, Brand, A, B, C, F> Lift2Dispatch<'a, Brand, A, B, C, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, Val> for F
Routes Fn(A, B) -> C closures to Lift::lift2.
impl<'a, Brand, A, B, C, F> Lift2Dispatch<'a, Brand, A, B, C, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, Val> for F
Routes Fn(A, B) -> C closures to Lift::lift2.
§Type Parameters
'a: The 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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>
§Type Signature
forall Brand A B C. Lift Brand => ((A, B) -> C, Brand A, Brand B) -> Brand C
§Parameters
self: The closure that takes owned values.fa: The first context.fb: The second context.
§Returns
A new context containing the result.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let z = lift2::<OptionBrand, _, _, _, _, _, _>(|a, b| a + b, Some(1), Some(2));
assert_eq!(z, Some(3));Source§impl<'a, Brand, A, B, C, D, F> Lift3Dispatch<'a, Brand, A, B, C, D, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, Val> for F
Routes Fn(A, B, C) -> D closures through Lift::lift2.
impl<'a, Brand, A, B, C, D, F> Lift3Dispatch<'a, Brand, A, B, C, D, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, Val> for F
Routes Fn(A, B, C) -> D closures through Lift::lift2.
§Type Parameters
'a: The lifetime.Brand: The brand.A: First.B: Second.C: Third.D: Result.F: Closure.
Source§fn dispatch(
self,
fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>,
fc: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, fc: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>
§Type Signature
forall Brand A B C D. Lift Brand => ((A, B, C) -> D, Brand A, Brand B, Brand C) -> Brand D
§Parameters
self: The closure that takes owned values.fa: First context.fb: Second context.fc: Third context.
§Returns
A new context containing the result.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let r = lift3::<OptionBrand, _, _, _, _, _, _, _, _>(
|a, b, c| a + b + c,
Some(1),
Some(2),
Some(3),
);
assert_eq!(r, Some(6));Source§impl<'a, Brand, A, B, C, D, E, Func> Lift4Dispatch<'a, Brand, A, B, C, D, E, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, Val> for Func
Routes Fn(A, B, C, D) -> E closures through Lift::lift2.
impl<'a, Brand, A, B, C, D, E, Func> Lift4Dispatch<'a, Brand, A, B, C, D, E, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, Val> for Func
Routes Fn(A, B, C, D) -> E closures through Lift::lift2.
§Type Parameters
'a: The lifetime.Brand: The brand.A: First.B: Second.C: Third.D: Fourth.E: Result.Func: Closure.
Source§fn dispatch(
self,
fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>,
fc: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>,
fd: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, fc: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, fd: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>
§Type Signature
forall Brand A B C D E. Lift Brand => ((A, B, C, D) -> E, Brand A, Brand B, Brand C, Brand D) -> Brand E
§Parameters
self: The closure that takes owned values.fa: First.fb: Second.fc: Third.fd: Fourth.
§Returns
Result context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let r = lift4::<OptionBrand, _, _, _, _, _, _, _, _, _, _>(
|a, b, c, d| a + b + c + d,
Some(1),
Some(2),
Some(3),
Some(4),
);
assert_eq!(r, Some(10));Source§impl<'a, Brand, A, B, C, D, E, G, Func> Lift5Dispatch<'a, Brand, A, B, C, D, E, G, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, Val> for Func
Routes Fn(A, B, C, D, E) -> G closures through Lift::lift2.
impl<'a, Brand, A, B, C, D, E, G, Func> Lift5Dispatch<'a, Brand, A, B, C, D, E, G, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, Val> for Func
Routes Fn(A, B, C, D, E) -> G closures through Lift::lift2.
§Type Parameters
'a: The lifetime.Brand: The brand.A: 1st.B: 2nd.C: 3rd.D: 4th.E: 5th.G: Result.Func: Closure.
Source§fn dispatch(
self,
fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
fb: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>,
fc: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>,
fd: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>,
fe: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, G>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, fb: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>, fc: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, C>, fd: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, D>, fe: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, E>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, G>
§Type Signature
forall Brand A B C D E G. Lift 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 owned values.fa: 1st.fb: 2nd.fc: 3rd.fd: 4th.fe: 5th.
§Returns
Result context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let r = lift5::<OptionBrand, _, _, _, _, _, _, _, _, _, _, _, _>(
|a, b, c, d, e| a + b + c + d + e,
Some(1),
Some(2),
Some(3),
Some(4),
Some(5),
);
assert_eq!(r, Some(15));Source§impl<'a, Brand, A, B, C, F> MapFirstDispatch<'a, Brand, A, B, C, <Brand as Kind_266801a817966495>::Of<'a, A, C>, Val> for F
Routes Fn(A) -> B closures to Bifunctor::map_first.
impl<'a, Brand, A, B, C, F> MapFirstDispatch<'a, Brand, A, B, C, <Brand as Kind_266801a817966495>::Of<'a, A, C>, Val> for F
Routes Fn(A) -> B closures to Bifunctor::map_first.
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the bifunctor.A: The type of the first value.B: The type of the first result.C: The type of the second value.F: The closure type.
Source§fn dispatch(
self,
fa: <Brand as Kind_266801a817966495>::Of<'a, A, C>,
) -> <Brand as Kind_266801a817966495>::Of<'a, B, C>
fn dispatch( self, fa: <Brand as Kind_266801a817966495>::Of<'a, A, C>, ) -> <Brand as Kind_266801a817966495>::Of<'a, B, C>
§Type Signature
forall Brand A B C. Bifunctor Brand => (A -> B, Brand A C) -> Brand B C
§Parameters
self: The closure that takes owned values.fa: The bifunctor value.
§Returns
A new bifunctor with the first value transformed.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = map_first::<ResultBrand, _, _, _, _, _>(|e| e + 1, Err::<i32, i32>(5));
assert_eq!(result, Err(6));Source§impl<'a, Brand, A, B, C, F> MapSecondDispatch<'a, Brand, A, B, C, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for F
Routes Fn(B) -> C closures to Bifunctor::map_second.
impl<'a, Brand, A, B, C, F> MapSecondDispatch<'a, Brand, A, B, C, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for F
Routes Fn(B) -> C closures to Bifunctor::map_second.
§Type Parameters
'a: The lifetime of the values.Brand: The brand of the bifunctor.A: The type of the first value.B: The type of the second value.C: The type of the second result.F: The closure type.
Source§fn dispatch(
self,
fa: <Brand as Kind_266801a817966495>::Of<'a, A, B>,
) -> <Brand as Kind_266801a817966495>::Of<'a, A, C>
fn dispatch( self, fa: <Brand as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Brand as Kind_266801a817966495>::Of<'a, A, C>
§Type Signature
forall Brand A B C. Bifunctor Brand => (B -> C, Brand A B) -> Brand A C
§Parameters
self: The closure that takes owned values.fa: The bifunctor value.
§Returns
A new bifunctor with the second value transformed.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = map_second::<ResultBrand, _, _, _, _, _>(|s| s * 2, Ok::<i32, i32>(5));
assert_eq!(result, Ok(10));Source§impl<'a, Brand, A, B, F> MapWithIndexDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, A) -> B closures to FunctorWithIndex::map_with_index.
impl<'a, Brand, A, B, F> MapWithIndexDispatch<'a, Brand, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, A) -> B closures to FunctorWithIndex::map_with_index.
§Type Parameters
'a: The lifetime of the values.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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
fn dispatch( self, fa: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>
§Type Signature
forall Brand A B. FunctorWithIndex Brand => ((Index, A) -> B, Brand A) -> Brand B
§Parameters
self: The closure that takes an index and owned values.fa: The functor instance containing the value(s).
§Returns
A new functor instance containing the result(s) of applying the function with index.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = map_with_index::<VecBrand, _, _, _, _>(|i, x: i32| x + i as i32, vec![10, 20, 30]);
assert_eq!(result, vec![10, 21, 32]);Source§impl<'a, Brand, A, F> PartitionDispatch<'a, Brand, A, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> bool closures to Filterable::partition.
impl<'a, Brand, A, F> PartitionDispatch<'a, Brand, A, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> bool closures to Filterable::partition.
§Type Parameters
'a: The lifetime of the values.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: <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: <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. Filterable Brand => (A -> bool, Brand A) -> (Brand A, Brand A)
§Parameters
self: The closure that takes owned values.fa: The filterable instance containing the value(s).
§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, Brand, A, E, O, F> PartitionMapDispatch<'a, Brand, A, E, O, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> Result<O, E> closures to Filterable::partition_map.
impl<'a, Brand, A, E, O, F> PartitionMapDispatch<'a, Brand, A, E, O, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(A) -> Result<O, E> closures to Filterable::partition_map.
§Type Parameters
'a: The lifetime of the values.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: <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: <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. Filterable Brand => (A -> Result O E, Brand A) -> (Brand E, Brand O)
§Parameters
self: The closure that takes owned values.fa: The filterable instance containing the value(s).
§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, Brand, A, E, O, F> PartitionMapWithIndexDispatch<'a, Brand, A, E, O, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Fwhere
Brand: FilterableWithIndex,
A: 'a,
E: 'a,
O: 'a,
Brand::Index: 'a,
F: Fn(Brand::Index, A) -> Result<O, E> + 'a,
Routes Fn(Brand::Index, A) -> Result<O, E> closures to FilterableWithIndex::partition_map_with_index.
impl<'a, Brand, A, E, O, F> PartitionMapWithIndexDispatch<'a, Brand, A, E, O, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Fwhere
Brand: FilterableWithIndex,
A: 'a,
E: 'a,
O: 'a,
Brand::Index: 'a,
F: Fn(Brand::Index, A) -> Result<O, E> + 'a,
Routes Fn(Brand::Index, A) -> Result<O, E> closures to FilterableWithIndex::partition_map_with_index.
§Type Parameters
'a: The lifetime of the values.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: <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: <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. FilterableWithIndex Brand => ((Index, A) -> Result O E, Brand A) -> (Brand E, Brand O)
§Parameters
self: The closure that takes an index and owned values.fa: The filterable instance containing the value(s).
§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_with_index::<VecBrand, _, _, _, _, _>(
|i, x: i32| if i < 2 { Ok(x) } else { Err(x) },
vec![10, 20, 30, 40],
);
assert_eq!(oks, vec![10, 20]);
assert_eq!(errs, vec![30, 40]);Source§impl<'a, Brand, A, F> PartitionWithIndexDispatch<'a, Brand, A, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, A) -> bool closures to FilterableWithIndex::partition_with_index.
impl<'a, Brand, A, F> PartitionWithIndexDispatch<'a, Brand, A, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for F
Routes Fn(Brand::Index, A) -> bool closures to FilterableWithIndex::partition_with_index.
§Type Parameters
'a: The lifetime of the values.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: <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: <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. FilterableWithIndex Brand => ((Index, A) -> bool, Brand A) -> (Brand A, Brand A)
§Parameters
self: The closure that takes an index and owned values.fa: The filterable instance containing the value(s).
§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 (not_satisfied, satisfied) =
partition_with_index::<VecBrand, _, _, _>(|i, _x: i32| i < 2, vec![10, 20, 30, 40]);
assert_eq!(satisfied, vec![10, 20]);
assert_eq!(not_satisfied, vec![30, 40]);Source§impl<'a, Brand, E, O> SeparateDispatch<'a, Brand, E, O, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>>where
Brand: Compactable,
E: 'a,
O: 'a,
Routes owned containers to Compactable::separate.
impl<'a, Brand, E, O> SeparateDispatch<'a, Brand, E, O, Val> for <Brand as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>>where
Brand: Compactable,
E: 'a,
O: 'a,
Routes owned containers to Compactable::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. Compactable 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 (errs, oks) = separate::<VecBrand, _, _, _, _>(vec![Ok(1), Err(2), Ok(3)]);
assert_eq!(oks, vec![1, 3]);
assert_eq!(errs, vec![2]);Source§impl<'a, FnBrand, Brand, A, B, F, Func> TraverseDispatch<'a, FnBrand, Brand, A, B, F, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Funcwhere
Brand: Traversable,
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 Traversable::traverse.
impl<'a, FnBrand, Brand, A, B, F, Func> TraverseDispatch<'a, FnBrand, Brand, A, B, F, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Funcwhere
Brand: Traversable,
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 Traversable::traverse.
The FnBrand parameter is unused by the Val path but is accepted for
uniformity with the Ref path.
§Type Parameters
'a: The lifetime of the values.FnBrand: The cloneable function brand (unused by Val path).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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>
fn dispatch( self, ta: <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. (Traversable Brand, Applicative F) => (A -> F B, Brand A) -> F (Brand B)
§Parameters
self: The closure that takes owned values.ta: 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, FnBrand, Brand, A, B, F, Func> TraverseWithIndexDispatch<'a, FnBrand, Brand, A, B, F, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Funcwhere
Brand: TraversableWithIndex,
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 TraversableWithIndex::traverse_with_index.
impl<'a, FnBrand, Brand, A, B, F, Func> TraverseWithIndexDispatch<'a, FnBrand, Brand, A, B, F, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Funcwhere
Brand: TraversableWithIndex,
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 TraversableWithIndex::traverse_with_index.
The FnBrand parameter is unused by the Val path but is accepted for
uniformity with the Ref path.
§Type Parameters
'a: The lifetime of the values.FnBrand: The cloneable function brand (unused by Val path).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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <F as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>
fn dispatch( self, ta: <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. (TraversableWithIndex Brand, Applicative F) => ((Index, A) -> F B, Brand A) -> F (Brand B)
§Parameters
self: The closure that takes an index and owned values.ta: The structure to traverse.
§Returns
The combined result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = traverse_with_index::<RcFnBrand, VecBrand, _, _, OptionBrand, _, _>(
|_i, x: i32| Some(x * 2),
vec![1, 2, 3],
);
assert_eq!(result, Some(vec![2, 4, 6]));Source§impl<'a, FnBrand, Brand, M, A, E, O, Func> WiltDispatch<'a, FnBrand, Brand, M, A, E, O, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Funcwhere
Brand: Witherable,
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 Witherable::wilt.
impl<'a, FnBrand, Brand, M, A, E, O, Func> WiltDispatch<'a, FnBrand, Brand, M, A, E, O, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Funcwhere
Brand: Witherable,
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 Witherable::wilt.
§Type Parameters
'a: The lifetime of the values.FnBrand: The cloneable function brand (unused by Val path).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: <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: <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. (Witherable Brand, Applicative M) => (A -> M (Result O E), Brand A) -> M (Brand E, Brand O)
§Parameters
self: The closure that takes owned values.ta: The structure to partition.
§Returns
The partitioned result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
types::*,
};
let result = wilt::<RcFnBrand, OptionBrand, OptionBrand, _, _, _, _, _>(
|a: i32| Some(if a > 2 { Ok(a) } else { Err(a) }),
Some(5),
);
assert_eq!(result, Some((None, Some(5))));Source§impl<'a, FnBrand, Brand, M, A, B, Func> WitherDispatch<'a, FnBrand, Brand, M, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Funcwhere
Brand: Witherable,
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 Witherable::wither.
impl<'a, FnBrand, Brand, M, A, B, Func> WitherDispatch<'a, FnBrand, Brand, M, A, B, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Val> for Funcwhere
Brand: Witherable,
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 Witherable::wither.
§Type Parameters
'a: The lifetime of the values.FnBrand: The cloneable function brand (unused by Val path).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: <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>,
) -> <M as Kind_cdc7cd43dac7585f>::Of<'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>>
fn dispatch( self, ta: <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. (Witherable Brand, Applicative M) => (A -> M (Option B), Brand A) -> M (Brand B)
§Parameters
self: The closure that takes owned values.ta: The structure to filter.
§Returns
The filtered result in the applicative context.
§Examples
use fp_library::{
brands::*,
functions::explicit::*,
};
let result = wither::<RcFnBrand, OptionBrand, OptionBrand, _, _, _, _>(
|a: i32| Some(if a > 2 { Some(a * 2) } else { None }),
Some(5),
);
assert_eq!(result, Some(Some(10)));Auto Trait Implementations§
impl Freeze for Val
impl RefUnwindSafe for Val
impl Send for Val
impl Sync for Val
impl Unpin for Val
impl UnsafeUnpin for Val
impl UnwindSafe for Val
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