Skip to main content

Module functor

Module functor 

Source
Expand description

Dispatch for Functor::map and RefFunctor::ref_map.

Provides the FunctorDispatch trait and a unified explicit::map free function that routes to the appropriate trait method based on the closure’s argument type.

§Examples

use fp_library::{
	brands::*,
	functions::explicit::*,
	types::*,
};

// Owned: dispatches to Functor::map
let y = map::<OptionBrand, _, _, _, _>(|x: i32| x * 2, Some(5));
assert_eq!(y, Some(10));

// By-ref: dispatches to RefFunctor::ref_map
let lazy = RcLazy::pure(10);
let mapped = map::<LazyBrand<RcLazyConfig>, _, _, _, _>(|x: &i32| *x * 2, &lazy);
assert_eq!(*mapped.evaluate(), 20);

Modules§

explicit
Explicit dispatch functions requiring a Brand turbofish.

Traits§

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

Functions§

map
Maps a function over a functor, inferring the brand from the container type.