Skip to main content

MapSecondDispatch

Trait MapSecondDispatch 

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

Trait that routes a map_second operation to the appropriate type class method.

The Marker type parameter is inferred from the closure’s argument type: Fn(B) -> C resolves to Val, Fn(&B) -> C resolves to Ref. The FA type parameter is inferred from the container argument: owned for Val dispatch, borrowed for Ref dispatch.

§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.
  • FA: The container type (owned or borrowed), inferred from the argument.
  • Marker: Dispatch marker type, inferred automatically.

Required Methods§

Source

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

Perform the dispatched map_second operation.

§Type Signature

(self, FA) -> Brand A C

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

Implementors§

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§

impl<'a, Brand, A, B, C, F> MapSecondDispatch<'a, Brand, A, B, C, <Brand as Kind_266801a817966495>::Of<'a, A, B>, Val> for F
where Brand: Bifunctor, A: 'a, B: 'a, C: 'a, F: Fn(B) -> C + 'a,

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.