Skip to main content

ApplySecondDispatch

Trait ApplySecondDispatch 

Source
pub trait ApplySecondDispatch<'a, Brand: Kind_cdc7cd43dac7585f, A: 'a, B: 'a, Marker> {
    type FB;

    // Required method
    fn dispatch(
        self,
        fb: Self::FB,
    ) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>;
}
Expand description

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

The Marker type parameter is an implementation detail resolved by the compiler from the container type; callers never specify it directly. Owned containers resolve to Val, borrowed containers resolve to Ref.

§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.
  • Marker: Dispatch marker type, inferred automatically. Either Val or Ref.

Required Associated Types§

Source

type FB

The type of the second container argument.

Required Methods§

Source

fn dispatch(self, fb: Self::FB) -> <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>

Perform the dispatched apply_second operation.

§Type Signature

(self, Self) -> Brand B

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

Implementors§

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§

type FB = &'b <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>
where Brand: ApplySecond, A: 'a + Clone, B: 'a + Clone,

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§

type FB = <Brand as Kind_cdc7cd43dac7585f>::Of<'a, B>