Skip to main content

Ref

Struct Ref 

Source
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>
where Brand: RefAlt, A: 'a + Clone,

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>

§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, FnBrand, Brand, A, B, WrappedFn> ApplyDispatch<'a, FnBrand, Brand, A, B, WrappedFn, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, WrappedFn>
where FnBrand: CloneFn<Ref> + 'a, Brand: RefSemiapplicative, A: 'a, B: 'a, WrappedFn: 'a, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, WrappedFn>: Into<&'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, <FnBrand as CloneFn<Ref>>::Of<'a, A, B>>>, 'a: 'b,

Routes borrowed containers to RefSemiapplicative::ref_apply.

§Type Parameters
  • 'a: The lifetime of the values.
  • 'b: The borrow lifetime.
  • 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: &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>

§Type Signature

forall Brand A B WrappedFn. (CloneFn FnBrand, RefSemiapplicative Brand, Into &Brand WrappedFn) => (&Brand WrappedFn, &Brand A) -> Brand B

§Parameters
  • self: The borrowed function container.
  • fa: The borrowed 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::*,
	functions::*,
};

let f = Some(std::rc::Rc::new(|x: &i32| *x * 2) as std::rc::Rc<dyn Fn(&i32) -> i32>);
let x = Some(5);
let y: Option<i32> = apply(&f, &x);
assert_eq!(y, Some(10));
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.

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

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

The type of the second container argument.
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.

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

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

The type of the second container argument.
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)
where Brand: RefBifoldable, FnBrand: LiftFn + 'a, A: 'a + Clone, B: 'a + Clone, C: 'a, F: Fn(C, &A) -> C + 'a, G: Fn(C, &B) -> C + 'a,

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

§Type Signature

forall Brand A B C. RefBifoldable Brand => (((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)
where Brand: RefBifoldable, FnBrand: LiftFn + 'a, A: Clone + 'a, B: Clone + 'a, M: Monoid + 'a, F: Fn(&A) -> M + 'a, G: Fn(&B) -> M + 'a,

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

§Type Signature

forall Brand A B M. (RefBifoldable Brand, 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)
where Brand: RefBifoldable, FnBrand: LiftFn + 'a, A: 'a + Clone, B: 'a + Clone, C: 'a, F: Fn(&A, C) -> C + 'a, G: Fn(&B, C) -> C + 'a,

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

§Type Signature

forall Brand A B C. RefBifoldable Brand => (((&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.

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

§Type Signature

forall Brand A B C D F. (RefBitraversable Brand, 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)
where Brand: RefBifunctor, A: 'a, B: 'a, C: 'a, D: 'a, F: Fn(&A) -> B + 'a, G: Fn(&C) -> D + 'a,

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>

§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 F
where 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>

§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: ToDynCloneFn> CloneFn<Ref> for FnBrand<P>

§Type Parameters
  • P: The reference-counted pointer type.
Source§

type Of<'a, A: 'a, B: 'a> = <P as RefCountedPointer>::Of<'a, dyn Fn(&A) -> B + 'a>

The type of the cloneable function wrapper. Read more
Source§

type PointerBrand = P

The pointer brand backing this function wrapper. Read more
Source§

impl ClosureMode for Ref

Source§

type SendTarget<'a, A: 'a, B: 'a> = dyn Fn(&A) -> B + Sync + Send + 'a

The unsized closure trait object type for this mode with Send + Sync bounds.
Source§

type Target<'a, A: 'a, B: 'a> = dyn Fn(&A) -> B + 'a

The unsized closure trait object type for this mode.
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.

§Type Parameters
  • 'a: The lifetime of the values.
  • Brand: The brand of the compactable.
  • A: The type of the value(s) inside the Option wrappers.
Source§

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

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
where Brand: RefFilterable, A: 'a + Clone, F: Fn(&A) -> bool + 'a,

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>

§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
where Brand: RefFilterable, A: 'a, B: 'a, F: Fn(&A) -> Option<B> + 'a,

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>

§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
where Brand: RefFilterableWithIndex, A: 'a, B: 'a, Brand::Index: 'a, F: Fn(Brand::Index, &A) -> Option<B> + 'a,

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>

§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
where Brand: RefFilterableWithIndex, A: 'a + Clone, Brand::Index: 'a, F: Fn(Brand::Index, &A) -> bool + 'a,

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>

§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
where Brand: RefFoldable, FnBrand: LiftFn + 'a, A: 'a + Clone, B: 'a, F: Fn(B, &A) -> B + 'a,

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

§Type Signature

forall Brand A B. RefFoldable Brand => ((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
where Brand: RefFoldableWithIndex, FnBrand: LiftFn + 'a, A: 'a + Clone, B: 'a, Brand::Index: 'a, F: Fn(Brand::Index, B, &A) -> B + 'a,

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

§Type Signature

forall Brand A B. RefFoldableWithIndex Brand => ((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
where Brand: RefFoldable, FnBrand: LiftFn + 'a, A: Clone + 'a, M: Monoid + 'a, F: Fn(&A) -> M + 'a,

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

§Type Signature

forall Brand A M. (RefFoldable Brand, 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
where Brand: RefFoldableWithIndex, FnBrand: LiftFn + 'a, A: Clone + 'a, M: Monoid + 'a, Brand::Index: 'a, F: Fn(Brand::Index, &A) -> M + 'a,

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

§Type Signature

forall Brand A M. (RefFoldableWithIndex Brand, 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
where Brand: RefFoldable, FnBrand: LiftFn + 'a, A: 'a + Clone, B: 'a, F: Fn(&A, B) -> B + 'a,

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

§Type Signature

forall Brand A B. RefFoldable Brand => ((&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
where Brand: RefFoldableWithIndex, FnBrand: LiftFn + 'a, A: 'a + Clone, B: 'a, Brand::Index: 'a, F: Fn(Brand::Index, &A, B) -> B + 'a,

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

§Type Signature

forall Brand A B. RefFoldableWithIndex Brand => ((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
where Brand: RefFunctor, A: 'a, B: 'a, F: Fn(&A) -> B + 'a,

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>

§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>>
where Brand: RefSemimonad, A: 'a, <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>: Clone,

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>

§Type Signature

forall Brand A. RefSemimonad Brand => &Brand (Brand A) -> Brand A

§Returns

A container with one layer of nesting removed.

§Examples
use fp_library::{
	brands::*,
	functions::explicit::*,
};

let x = Some(Some(5));
let result = join::<OptionBrand, _, _>(&x);
assert_eq!(result, Some(5));
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
where Brand: RefLift, A: 'a, B: 'a, C: 'a, F: Fn(&A, &B) -> C + 'a,

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>

§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
where Brand: RefLift, A: Clone + 'a, B: Clone + 'a, C: 'a, D: 'a, F: Fn(&A, &B, &C) -> D + 'a,

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>

§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
where Brand: RefLift, A: Clone + 'a, B: Clone + 'a, C: Clone + 'a, D: 'a, E: 'a, Func: Fn(&A, &B, &C, &D) -> E + 'a,

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>

§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
where Brand: RefLift, A: Clone + 'a, B: Clone + 'a, C: Clone + 'a, D: Clone + 'a, E: 'a, G: 'a, Func: Fn(&A, &B, &C, &D, &E) -> G + 'a,

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>

§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, C, F> MapFirstDispatch<'a, Brand, A, B, C, &'b <Brand as Kind_266801a817966495>::Of<'a, A, C>, Ref> for F
where Brand: RefBifunctor, A: 'a, B: 'a, C: Clone + 'a, F: Fn(&A) -> B + 'a,

Routes Fn(&A) -> B closures to RefBifunctor::ref_map_first.

The container must be passed by reference (&p).

§Type Parameters
  • 'a: The lifetime of the values.
  • 'b: The borrow lifetime.
  • 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 (must be Clone).
  • F: The closure type.
Source§

fn dispatch( self, fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, C>, ) -> <Brand as Kind_266801a817966495>::Of<'a, B, C>

§Type Signature

forall Brand A B C. RefBifunctor Brand => (&A -> B, &Brand A C) -> Brand B C

§Parameters
  • self: The closure that takes references.
  • fa: A reference to the bifunctor value.
§Returns

A new bifunctor with the first value transformed.

§Examples
use fp_library::{
	brands::*,
	functions::explicit::*,
};
let x = Err::<i32, i32>(5);
let result = map_first::<ResultBrand, _, _, _, _, _>(|e: &i32| *e + 1, &x);
assert_eq!(result, Err(6));
Source§

impl<'a, 'b, Brand, A, B, C, F> MapSecondDispatch<'a, Brand, A, B, C, &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, Ref> for F
where Brand: RefBifunctor, A: Clone + 'a, B: 'a, C: 'a, F: Fn(&B) -> C + 'a,

Routes Fn(&B) -> C closures to RefBifunctor::ref_map_second.

The container must be passed by reference (&p).

§Type Parameters
  • 'a: The lifetime of the values.
  • 'b: The borrow lifetime.
  • Brand: The brand of the bifunctor.
  • A: The type of the first value (must be Clone).
  • B: The type of the second value.
  • C: The type of the second result.
  • F: The closure type.
Source§

fn dispatch( self, fa: &'b <Brand as Kind_266801a817966495>::Of<'a, A, B>, ) -> <Brand as Kind_266801a817966495>::Of<'a, A, C>

§Type Signature

forall Brand A B C. RefBifunctor Brand => (&B -> C, &Brand A B) -> Brand A C

§Parameters
  • self: The closure that takes references.
  • fa: A reference to the bifunctor value.
§Returns

A new bifunctor with the second value transformed.

§Examples
use fp_library::{
	brands::*,
	functions::explicit::*,
};
let x = Ok::<i32, i32>(5);
let result = map_second::<ResultBrand, _, _, _, _, _>(|s: &i32| *s * 2, &x);
assert_eq!(result, Ok(10));
Source§

impl<'a, 'b, Brand, A, B, F> MapWithIndexDispatch<'a, Brand, A, B, &'b <Brand as Kind_cdc7cd43dac7585f>::Of<'a, A>, Ref> for F
where 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>

§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
where Brand: RefFilterable, A: 'a + Clone, F: Fn(&A) -> bool + 'a,

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

§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
where Brand: RefFilterable, A: 'a, E: 'a, O: 'a, F: Fn(&A) -> Result<O, E> + 'a,

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

§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
where Brand: RefFilterableWithIndex, 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 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>)

§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
where Brand: RefFilterableWithIndex, A: 'a + Clone, Brand::Index: 'a, F: Fn(Brand::Index, &A) -> bool + 'a,

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

§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: ToDynSendFn + ToDynCloneFn> SendCloneFn<Ref> for FnBrand<P>

§Type Parameters
  • P: The reference-counted pointer type.
Source§

type Of<'a, A: 'a, B: 'a> = <P as SendRefCountedPointer>::Of<'a, dyn Fn(&A) -> B + Sync + Send + 'a>

The type of the thread-safe cloneable function wrapper. Read more
Source§

impl<'a, Brand, E, O> SeparateDispatch<'a, Brand, E, O, Ref> for &<Brand as Kind_cdc7cd43dac7585f>::Of<'a, Result<O, E>>
where Brand: RefCompactable, E: 'a + Clone, O: 'a + Clone,

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 the Result wrappers.
  • O: The success type inside the Result wrappers.
Source§

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 Func
where 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>>

§Type Signature

forall Brand A B F. (RefTraversable Brand, 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 Func
where 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>>

§Type Signature

forall Brand A B F. (RefTraversableWithIndex Brand, 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 Func
where 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>)>

§Type Signature

forall Brand M A E O. (RefWitherable Brand, 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 Func
where 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>>

§Type Signature

forall Brand M A B. (RefWitherable Brand, 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]));
Source§

impl<'a, A: 'a, B: 'a> InferableFnBrand<FnBrand<ArcBrand>, A, B, Ref> for Arc<dyn Fn(&A) -> B + Send + Sync + 'a>

Maps Arc<dyn Fn(&A) -> B + Send + Sync> back to ArcFnBrand (Ref mode).

§Type Parameters
  • 'a: The lifetime of the wrapped function.
  • A: The input type of the wrapped function.
  • B: The output type of the wrapped function.
Source§

impl<'a, A: 'a, B: 'a> InferableFnBrand<FnBrand<RcBrand>, A, B, Ref> for Rc<dyn Fn(&A) -> B + 'a>

Maps Rc<dyn Fn(&A) -> B> back to RcFnBrand (Ref mode).

§Type Parameters
  • 'a: The lifetime of the wrapped function.
  • A: The input type of the wrapped function.
  • B: The output type of the wrapped function.

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

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

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pipe for T

Source§

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

Pipes self into a function, enabling left-to-right composition. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.