Skip to main content

ApplyDispatch

Trait ApplyDispatch 

Source
pub trait ApplyDispatch<'a, FnBrand, Brand: Kind_cdc7cd43dac7585f, A: 'a, B: 'a, WrappedFn: 'a, FA, Marker> {
    // Required method
    fn dispatch(self, fa: FA) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>;
}
Expand description

Trait that routes an apply operation to the appropriate type class method.

The Marker type parameter selects Val or Ref dispatch:

§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.
  • FA: The value container type.
  • Marker: Dispatch marker type, inferred automatically.

Required Methods§

Source

fn dispatch(self, fa: FA) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>

Perform the dispatched apply operation.

§Type Signature

(self, FA) -> Brand B

§Parameters
  • self: The function container implementing this dispatch.
  • 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));

Implementors§

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§

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.