new

Function new 

Source
pub fn new<'a, Brand, A, B>(
    f: impl 'a + Fn(A) -> B,
) -> <Brand as Function>::Of<'a, A, B>
where Brand: Function,
Expand description

Creates a new function wrapper.

Free function version that dispatches to the type class’ associated function.

§Type Signature

forall a b. Function f => (a -> b) -> f a b

§Type Parameters

  • Brand: The brand of the function wrapper.
  • A: The input type of the function.
  • B: The output type of the function.

§Parameters

  • f: The closure to wrap.

§Returns

The wrapped function.

§Examples

use fp_library::classes::function::new;
use fp_library::brands::RcFnBrand;

let f = new::<RcFnBrand, _, _>(|x: i32| x * 2);
assert_eq!(f(5), 10);